I'm getting CORS policy issue with the pages funct...
# workers-help
a
Hi, I tried to set Access-Control-Allow-Origin: * in the /functions/_middleware.ts but it still showing the the error, plz check the code below,

https://cdn.discordapp.com/attachments/1108380350826168320/1108380351358832650/Screenshot_from_2023-05-17_18-57-37.png

https://cdn.discordapp.com/attachments/1108380350826168320/1108380351887327292/Screenshot_from_2023-05-17_19-00-20.png

https://cdn.discordapp.com/attachments/1108380350826168320/1108380352235442276/Screenshot_from_2023-05-17_19-00-36.png

https://cdn.discordapp.com/attachments/1108380350826168320/1108380352541642933/Screenshot_from_2023-05-17_19-01-01.png

n
You need to allow
OPTIONS
requests, and ensure that all requests with OPTIONS method is replied with, with the appropriate CORS headers.
for example, if
await next()
fails here, so will your CORS headers.
to sum it up, the preflight request is failing because it's not receiving 200 OK, and most likely 404 File Not Found or 405 Method Not Allowed, you can check the network tab for the specifics. (or even it's the 500 you're returning in your catch block)
a
@nora thanks