-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: exploring multi site support in app router
- Loading branch information
1 parent
e4055dd
commit fb0e26b
Showing
4 changed files
with
61 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { getHeadstartWPConfig, getSiteByHost } from '@headstartwp/core'; | ||
import { headers } from 'next/headers'; | ||
|
||
/** | ||
* How to make this work in edge runtimes? | ||
*/ | ||
export async function loadHeadstartWPConfig() { | ||
const config = getHeadstartWPConfig(); | ||
const headersList = headers(); | ||
|
||
const site = headersList.get('x-headstartwp-site'); | ||
|
||
if (site) { | ||
return getSiteByHost(site); | ||
} | ||
|
||
return config; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
export * from './data'; | ||
export * from './type'; | ||
export * from './config'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import { AppMiddleware } from '@headstartwp/next/middlewares'; | ||
import { NextRequest } from 'next/server'; | ||
|
||
export const config = { | ||
matcher: [ | ||
/* | ||
* Match all paths except for: | ||
* 1. /api routes | ||
* 2. /_next (Next.js internals) | ||
* 3. /fonts (inside /public) | ||
* 4. all root files inside /public (e.g. /favicon.ico) | ||
*/ | ||
'/((?!api|cache-healthcheck|_next|fonts[\\w-]+\\.\\w+).*)', | ||
], | ||
}; | ||
|
||
export async function middleware(req: NextRequest) { | ||
return AppMiddleware(req, { appRouter: true }); | ||
} |