Open Git-I985 opened 3 months ago
this seems to be intentional. @huozhi could you please tell why you avoided checking for /route while checking for metadata route here?
The crutch solution with rewrites
src/app/proxy-sitemap/route.ts
export function GET(request: Request) {
// ... your logic here
}
// next.config.js
const nextConfig = {
rewrites: () => {
return [
{
source: '/robots.txt',
destination: '/proxy-robots',
},
{
source: '/sitemap.xml',
destination: '/proxy-sitemap',
}
];
}
}
module.exports = nextConfig
Link to the code that reproduces this issue
https://github.com/Git-I985/next-custom-page-extension-custom-sitemap-route-bug
To Reproduce
["x.ts", "x.tsx"]
sitemap.xml
directory insrc/app
route.x.ts
with contentnpm run dev
in terminalhttp://localhost:3000/sitemap.xml
export const GET = () => new Response('It will return file content because route starts with "sitemap"')
instead of response textCurrent vs. Expected behavior
I expect
route.x.ts
return me actual response instead of page with route source codeProvide environment information
Which area(s) are affected? (Select all that apply)
Middleware, Module Resolution, Navigation, Parallel & Intercepting Routes
Which stage(s) are affected? (Select all that apply)
next dev (local), next build (local), next start (local)
Additional context
It reproduced only if there is word
sitemap
in the begining of the route name, also same issue reproduced with the namerobots
No response