Last active
June 13, 2025 08:28
-
-
Save thatbeautifuldream/f35cbded357bd2a3716b7ed6045729ce to your computer and use it in GitHub Desktop.
Get hostname through headers on the server side in next.js
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
| import { headers } from "next/headers"; | |
| export function page() { | |
| const headersList = headers(); | |
| const hostname = headersList.get("x-forwarded-host"); | |
| return <pre>{hostname}</pre>; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment