Skip to content

Instantly share code, notes, and snippets.

@mktakuya
Created May 6, 2021 12:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mktakuya/5cc314d778271cf67d1778fe6da0773c to your computer and use it in GitHub Desktop.
Save mktakuya/5cc314d778271cf67d1778fe6da0773c to your computer and use it in GitHub Desktop.
api.yuru28.com/feed にあるRSSフィードを、 yuru28.com/feed でそのままプロキシするNext.jsのコード
import { GetServerSidePropsContext } from "next"
export async function getServerSideProps({ res }: GetServerSidePropsContext) {
const feedUrl = "https://api.yuru28.com/feed"
await fetch(feedUrl)
.then((response) => response.text())
.then((data) => {
res.statusCode = 200
res.setHeader("Content-Type", "application/xml")
res.end(data)
})
return {
props: {},
}
}
const Page = () => null
export default Page
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment