Skip to content

Instantly share code, notes, and snippets.

@thatbeautifuldream
Last active June 13, 2025 08:28
Show Gist options
  • Select an option

  • Save thatbeautifuldream/f35cbded357bd2a3716b7ed6045729ce to your computer and use it in GitHub Desktop.

Select an option

Save thatbeautifuldream/f35cbded357bd2a3716b7ed6045729ce to your computer and use it in GitHub Desktop.
Get hostname through headers on the server side in next.js
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