From 6726557463932a12589b037647711d237ed184c0 Mon Sep 17 00:00:00 2001 From: yoshinorin Date: Mon, 1 Jan 2024 21:32:49 +0900 Subject: [PATCH] tmp --- src/app/feeds/index.xml/route.ts | 13 +++++++++++-- src/app/sitemap.xml/route.ts | 24 +++++++++++++----------- 2 files changed, 24 insertions(+), 13 deletions(-) diff --git a/src/app/feeds/index.xml/route.ts b/src/app/feeds/index.xml/route.ts index 628d4f3..3425616 100644 --- a/src/app/feeds/index.xml/route.ts +++ b/src/app/feeds/index.xml/route.ts @@ -9,11 +9,20 @@ import { getRequestContext } from '../../../utils/requestContext'; //export async function get(ctx: any) { export async function GET() { const response: Response = await getFeed(getRequestContext(headers())); - // ctx.res.statusCode = response.status; // TODO if (response.status !== 200) { - return new Response(new Blob(), { status: 404 }); + /* NOTE: + res.statusCode = response.status; + res.send; + */ + return new Response('', { + status: 404 , + headers: { + "Content-Type": "text/xml", + }, + }); } + let feedResponses = await response.json() as Array; const feeds = feedResponses.map(feed => { return { diff --git a/src/app/sitemap.xml/route.ts b/src/app/sitemap.xml/route.ts index 662bf69..cac026f 100644 --- a/src/app/sitemap.xml/route.ts +++ b/src/app/sitemap.xml/route.ts @@ -5,22 +5,24 @@ import { getSitemap } from '../../api/sitemap'; import { generateSitemapString } from '../../services/sitemap'; import { url } from '../../../config'; import { getRequestContext } from '../../utils/requestContext'; +import { NextApiResponse } from 'next'; -export async function GET() { +export async function GET(res: NextApiResponse) { const response: Response = await getSitemap(getRequestContext(headers())); - /* TODO - ctx.res.statusCode = response.status; - - let sitemapResponse = null; if (response.status !== 200) { - return { - props: { - statusCode: 404 - } - } + /* NOTE: + res.statusCode = response.status; + res.send; + */ + return new Response('', { + status: 404 , + headers: { + "Content-Type": "text/xml", + }, + }); } - */ + let sitemapResponse = await response.json() as Array; const sitemap = sitemapResponse.map(sitemap => { return {