melonpan icon indicating copy to clipboard operation
melonpan copied to clipboard

CORS policy

Open jetgriffin opened this issue 2 years ago • 0 comments

Captura de pantalla de 2022-10-17 20-50-11 This error occurs because the Access-Control-Allow-Origin: * header is not present in the new Response() object. In the dev environment we need the headers so the client has not problems in reaching the requested resources. Fix: to add a new property private headers: Headers; in Melonpan, which contains all set headers, in order to pass them as a param in all the new Response() objects. So now we just need to call melonpan.cors() to set all the default headers, which are:

[
  ["Access-Control-Allow-Origin", "*"]
  ["Access-Control-Allow-Methods", "POST, GET, OPTIONS"]
  ["Access-Control-Allow-Headers", "X-PINGOTHER, Content-Type"]
  ["Access-Control-Max-Age", "86400"]
]

I shall make a pull request to fix it.

jetgriffin avatar Oct 18 '22 00:10 jetgriffin