Created
February 14, 2023 14:30
-
-
Save Wellers0n/b1c148fa47fa962c543f719ff260a249 to your computer and use it in GitHub Desktop.
redirect url nextjs url from http to htttps
This file contains hidden or 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
if ( | |
PRODUCTION_ENV && | |
request.headers.get("x-forwarded-proto") !== "https" | |
) { | |
const hostname = request.headers.get("host") || request.nextUrl.hostname; | |
return NextResponse.redirect( | |
`https://${hostname}${request.nextUrl.pathname}` | |
); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment