robmarscher
CDCloudflare Developers
•Created by ysm on 4/13/2023 in #pages-help
Does pages support Next.js rewrites?
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
15 replies
CDCloudflare Developers
•Created by ysm on 4/13/2023 in #pages-help
Does pages support Next.js rewrites?
@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
15 replies