Cloudflare Pages `_headers` not applying to url?

Hello community,

I am trying out Cloudflare Pages and I am particularly interested in the _headers and _redirects capabilities.

/.well-known/matrix/*
  Access-Control-Allow-Origin: *
  Content-Type: application/json

However, when I curl my file, the returned value does not match what I specified.

% curl -i https://udia.ca/.well-known/matrix/server
HTTP/2 200
date: Wed, 17 Nov 2021 16:57:54 GMT
content-type: application/octet-stream
content-length: 39
cache-control: public, max-age=0, must-revalidate
etag: "7d8849108704257dd9c077eda44257de"
expect-ct: max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct"
report-to: {"endpoints":[{"url":"https:\/\/a.nel.cloudflare.com\/report\/v3?s=GyM%2BQ17m3%2Bk04WUa2vId4fk33Xdz%2BqIYTJnL9uLihTbAYSg85dtxTqXot0uuK%2ByFImAl4MCV2jvmEU0YiZL%2BMHpTnAUYYoKA08NDbaUUssdZ8g63gO7AwhYAOky2QZg0OjJIL93W"}],"group":"cf-nel","max_age":604800}
nel: {"success_fraction":0,"report_to":"cf-nel","max_age":604800}
vary: Accept-Encoding
cf-cache-status: DYNAMIC
strict-transport-security: max-age=0; includeSubDomains
server: cloudflare
cf-ray: 6afa80313b8e8353-ORD
alt-svc: h3=":443"; ma=86400, h3-29=":443"; ma=86400, h3-28=":443"; ma=86400, h3-27=":443"; ma=86400

{
        "m.server": "matrix.udia.ca:8448"
}

The Access-Control-Allow-Origin header and the Content-Type headers do not match. Any guidance would be appreciated, thanks!

The _headers and _redirects files must be put in the folder where the files go after the build. The /dist folder, normally.

I put them in the folder where I have the favicon.ico file, the /static folder.

Ahh- it’s literally in the first paragraph of the docs. Thanks!
https://developers.cloudflare.com/pages/platform/headers

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.