11 Replies
Not at the moment. Should be coming in the new routing system.
how about headers and redirects in next.config.js?
It's the same with both of those.
Thanks!
Is there any thread or github issue or something I can follow for this update?
GitHub
Proposed Changes to use the Vercel Build Output for Routing · Issue...
Hello, this issue outlines the proposed changes that I would like to make to how next-on-pages handles routing. The Vercel build output config contains the different steps taken during the routing ...
Wow Thanks you for quick reply
Hi, @Better James .
This is now supported, right?
Yes it should be supported for several months now 🙂
@Better James do you know if it can rewrite to an external destination (another CF worker hosting an API server)? I am getting 503 cloudflare network errors and unable to see much from the logs. The Pages docs on proxying redirects says it can only proxy relative URLs. So that makes me think it isn't supported for the NextJS rewrites. https://developers.cloudflare.com/pages/platform/redirects/#proxying
Redirects · Cloudflare Pages docs
To use redirects on Cloudflare Pages, declare your redirects in a plain text file called _redirects without a file extension, in the output folder of …
Next.js rewrites should work fine
Not sure about rewriting to cloudflare hosted sites though since I only work on next-on-pages, not at cloudflare
Thanks a lot for the reply. It kept me from going down the wrong rabbit hole. There was an issue with the environment variable used for my rewrite destination. I read a bunch of your PR, the technical explanation of next-on-pages routing and looked at the unminified output files. The nextjs config rewrites are put into the built routing config in the filesystem phase. The fetch handler for the worker calls generateResponse after matching the route. If the matching route is a url, it uses fetch to get a response from the remote url. Makes sense. https://github.com/cloudflare/next-on-pages/blob/main/packages/next-on-pages/templates/_worker.js/handleRequest.ts#L73
Yep, that sounds about right!