melonpan
melonpan copied to clipboard
CORS policy
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.