Are you trying to publish a Worker, or a Pages project?
Are you trying to publish a Worker, or a Pages project?
wrangler./functions are working fine_middleware.ts just adds CORS headers, works fine on the other functionsfunction/ work fine. every other URL automatically breaks. even the 404.html is outnpm build just to confirm that everything's there + permissions on the edgeUncaught ReferenceError: process is not defined
wrangler pages functions buildaeonquake.eu.orgwrangler/functions_middleware.tsfunction/404.htmlnpm buildwrangler pages functions buildaeonquake.eu.orgexport const CORSHeaders: PagesFunction<{}> = async ({ request, env, next, data }): Promise<Response> => {
let newRes = (await next()).clone();
newRes.headers.set("Access-Control-Allow-Origin", "*");
newRes.headers.set("Access-Control-Allow-Headers", "*");
newRes.headers.set("Access-Control-Allow-Methods", "*");
return newRes;
};
export const onRequest = [CORSHeaders];export const onRequest = async ({ next }) => {
let response = await next()
const headers = new Headers([...response.headers.entries()])
// set cors headers
headers.set('x-new-header', 'new value')
response = new Response([101, 204, 205, 304].includes(response.status) ? null : response.body, { ...response, headers })
return response
}