Why do my Cloudflare Pages Functions work on pages.dev but return 404 on my custom domain?

Was this question useful?Community ranking

Answers

1 answer

If it works on `pages.dev`, the deployed Function is probably fine; the custom hostname is usually pointing at the wrong place or hasn’t been attached and activated for that Pages project. In Workers & Pages, open the project’s Custom domains tab and make sure that exact hostname is listed and active, then check its DNS is the record Cloudflare expects. If the domain reaches the project but only one URL 404s, compare the request path with your `functions/` file path: Pages Functions use file-based routing. Also check the deployed `_routes.json`, because an `exclude` rule wins over an `include` rule and can stop the Function from running. Test the same path and method on both hosts after a fresh deploy.

Was this answer helpful?Community ranking

Your answer

Sign in to answer.

Keep exploring

Similar questions

Browse all