Last active
September 7, 2020 07:30
-
-
Save hrdtbs/8d5c9e5cd11b80d9a9e2071edc521288 to your computer and use it in GitHub Desktop.
Redirect to external page on Next.js
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
import { DocumentContext } from "next/document" | |
import React from "react" | |
const Page = () => { | |
return null | |
} | |
const Location = "hoge" | |
export const getServerSideProps = async (ctx: DocumentContext) => { | |
if (ctx.res) { | |
ctx.res.writeHead(301, { Location, "Content-Type": "hoge" }) | |
ctx.res.end() | |
} | |
return { props: {} } | |
} | |
export default Page |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment