Skip to content

Commit

Permalink
Add MIME type
Browse files Browse the repository at this point in the history
  • Loading branch information
kevin940726 committed Aug 4, 2023
1 parent 330a3c3 commit 54c9ca0
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/app/rss.xml/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { getPosts } from '@/internals/posts';
import siteMetadata from '@/siteMetadata';

export const dynamic = 'force-dynamic';
// export const revalidate = 0; // Cache forever like a static file

export async function GET() {
const feed = new RSS({
Expand Down Expand Up @@ -31,7 +30,7 @@ export async function GET() {
url: postUrl,
guid: postUrl,
date: post.frontmatter.date,
enclosure: image ? { url: image } : undefined,
enclosure: image ? { url: image, type: 'image/png' } : undefined,
custom_elements: contentHtml
? [{ 'content:encoded': `<![CDATA[${contentHtml}]` }]
: undefined,
Expand All @@ -40,5 +39,7 @@ export async function GET() {

const xml = feed.xml({ indent: true });

return new Response(xml, { headers: { 'Content-Type': 'text/xml' } });
return new Response(xml, {
headers: { 'Content-Type': 'application/rss+xml; charset=UTF-8' },
});
}

0 comments on commit 54c9ca0

Please sign in to comment.