File tree Expand file tree Collapse file tree 3 files changed +7
-5
lines changed
Expand file tree Collapse file tree 3 files changed +7
-5
lines changed Original file line number Diff line number Diff line change 11import { NextResponse , type NextRequest } from "next/server" ;
2- import { serverEnv } from "./utils/env/server " ;
2+ import { SERVER_URL_KEY } from "./utils/constants " ;
33
44/**
55 * Nextjs bypass to set the server URL in the request headers so it can be read while in server components.
66 */
77export default async function middleware ( request : NextRequest ) {
88 const headers = new Headers ( request . headers ) ;
9- headers . set ( serverEnv . SERVER_URL_KEY , request . url ) ;
9+ headers . set ( SERVER_URL_KEY , request . url ) ;
1010 return NextResponse . next ( { headers } ) ;
1111}
1212
1313export const config = {
1414 matcher : [ "/((?!api|_next|_vercel|.*\\..*).*)" ] ,
15- unstable_allowDynamic : [ "/node_modules/elysia/dist/index.mjs" ] ,
1615} ;
Original file line number Diff line number Diff line change 1+ // Note: bug in nodejs cant import serverEnv into middleware.ts
2+ export const SERVER_URL_KEY = "x-url" ;
Original file line number Diff line number Diff line change 1+ import { SERVER_URL_KEY } from "@/utils/constants" ;
12import { Elysia , t } from "elysia" ;
23
34const {
@@ -13,7 +14,7 @@ const {
1314 } ,
1415 ) ,
1516 AUTH_COOKIE : t . Literal ( "auth" , { error : "AUTH_COOKIE not set!" } ) ,
16- SERVER_URL_KEY : t . Literal ( "x-url" , { error : "SERVER_URL not set!" } ) ,
17+ SERVER_URL_KEY : t . Literal ( SERVER_URL_KEY , { error : "SERVER_URL not set!" } ) ,
1718 SEVEN_DAYS : t . Integer ( { minimum : 1 , error : "SEVEN_DAYS not set!" } ) ,
1819 } ) ,
1920} ) ;
@@ -23,7 +24,7 @@ const serverEnvResult = serverSchema.safeParse({
2324 SECRET : process . env . SECRET ,
2425 NODE_ENV : process . env . NODE_ENV ,
2526 AUTH_COOKIE : "auth" ,
26- SERVER_URL_KEY : "x-url" ,
27+ SERVER_URL_KEY ,
2728 SEVEN_DAYS : 60 * 60 * 24 * 7 , // 7 days in seconds
2829} ) ;
2930
You can’t perform that action at this time.
0 commit comments