Link to XML endpoint does not work #3407
-
Describe the bugI've added the following file to function xml() {
return `<?xml version="1.0"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
<channel>
<title>Blog</title>
<description>My blogs</description>
<link>https://blog.domain.com/</link>
<lastBuildDate>${new Date().toUTCString()}</lastBuildDate>
<pubDate>${new Date().toUTCString()}</pubDate>
<language>en-us</language>
<copyright>Copyright 2021</copyright>
<atom:link href="https://blog.domain.com/rss.xml" rel="self" type="application/rss+xml"/>
<generator>website</generator>
<item>
<title>Title</title>
<link>https://blog.domain.com/slug</link>
<guid isPermaLink="true">https://blog.domain.com/slug</guid>
<atom:link href="https://blog.domain.com/slug" rel="self"></atom:link>
<pubDate>${new Date().toUTCString()}</pubDate>
<description>summary</description>
</item>
</channel>
</rss>`
}
export async function get() {
const headers = {
'Cache-Control': 'max-age=0, s-maxage=3600',
'Content-Type': 'application/xml',
}
return {
headers,
body: xml(),
}
} This is intended to be a RSS XML feed. In
This does not work as expected: sveltekit-endpoint-xml-bug.movWhen I click on the link, I get:
However, on refreshing the page it works as expected. The build folder contains $ tree build
build
├── _app
│ ├── chunks
│ │ └── vendor-f0095a1c.js
│ ├── error.svelte-ef333d6a.js
│ ├── layout.svelte-2102a60c.js
│ ├── manifest.json
│ ├── pages
│ │ └── index.svelte-1c0b251e.js
│ └── start-5b26607b.js
├── favicon.png
├── index.html
└── rss.xml I suspect something in routing to the internal link is not working as expected. In my other project, the internal link tries to request https://github.com/kdheepak/svelte-kit-rss-test Reproductionhttps://github.com/kdheepak/svelte-kit-rss-test Logs404
Not found: /rss.xml
_get_navigation_result@http://localhost:3000/_app/start-5b26607b.js:1:17905
update@http://localhost:3000/_app/start-5b26607b.js:1:15818
handle_navigation@http://localhost:3000/_app/start-5b26607b.js:1:15735
_navigate@http://localhost:3000/_app/start-5b26607b.js:1:12141
init_listeners/<@http://localhost:3000/_app/start-5b26607b.js:1:9635
Severityserious, but I can work around it Additional InformationMy workaround is to use |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
This is intended behavior, use https://kit.svelte.dev/docs#anchor-options-rel-external as mentioned by the docs to link to an endpoint. |
Beta Was this translation helpful? Give feedback.
-
Is this answer still revalent? |
Beta Was this translation helpful? Give feedback.
This is intended behavior, use https://kit.svelte.dev/docs#anchor-options-rel-external as mentioned by the docs to link to an endpoint.