For Workers & Pages, what is the name of the domain?
kalkulacka.one
What is the issue or error you’re encountering
How to set custom Content-Type
for workers static assets?
kalkulacka.one
How to set custom Content-Type
for workers static assets?
Looks like I can’t edit the post… My current solution is using a worker with "run_worker_first": true
but thats not ideal:
export default {
async fetch(request, env, ctx) {
const url = new URL(request.url);
if (url.pathname.startsWith('/.well-known/matrix')) {
let response = await env.ASSETS.fetch(request);
response = new Response(response.body, response);
response.headers.set('Content-Type', 'application/json');
return response;
}
url.hostname = `www.${url.hostname}`;
return Response.redirect(url.toString(), 301);
},
};
I don’t see it in the documentation yet, but support for _headers files as supported in Pages recently landed in Workers Assets (this PR from 3 weeks ago).
I haven’t tried it myself but you should be able to add headers for static assets this way now, avoiding the Worker invocation.
This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.