Cloudflare Pages: get rid of redundat 308 redirect

@Walshy @matteo It’s been half a year since last update on this topic. Is there at least any workaround? I’m trying to use workers to prevent the redirect, but no luck. Can we expect this redundant redirect being addressed in the next few months or we should forget about it and use other tools for deploying statically generated websites? I love Cloudflare and wouldn’t want to pull the plug.

Ok I found a decent workaround: I created a routed proxy worker that basically adds trailing slash in the request, fetches data from *.pages.dev with that slash at the end to prevent extra redirects, then sets proper content type on response for assets (default header returns text/html for css and js…) and returns the updated response with all other headers passed from the original *.pages.dev response.

simplified wrangler.toml can look like this:

name = "example-website-proxy"
main = "worker.ts"
compatibility_date = "2022-08-23"
account_id = "xxx"
route = "www.example-website.com/*"

If anyone is interested how the worker file should look like, let me know - I’ll create a simplified version.

Deploying via wrangler publish works like a charm.

@msajnog93 I’d like to see what you have setup if you don’t mind sharing we have the same issue.

We are facing something we assume is related and was first reported here

and that is that /pages/test.html gets a 308 to /pages/test. We assume this behavior must be related to this issue since otherwise there could be conflicts. On the other hand it can also serve as a very crude workaround for OPs issue since the way it’s implemented non trailing slash URLs seem to be reserved for permalink of html files.

It’s difficult to understand how the decision was made to have a default that serves anything else then just the file as is. It’s great to give the option to configure permalinks but it should be as an option.

Due to the issues listed by OP and the work required for migration, e.g. CI & CB tools and scripts, this is preventing us from migrating to Cloudflare Pages compared to alternatives so we added our vote as well to the feature request.