Fix Url-Shorten-Worker API Error: CORS Solution
Question
Wanted to debug Url-Shorten-Worker, saved index.html on local computer, called the server API at https://1way.eu.org/, got an error
Access to fetch at 'https://1way.eu.org/bodongshouqulveweifengci' from origin 'null' has been blocked by CORS policy: Request header field content-type is not allowed by Access-Control-Allow-Headers in preflight response.
Asked GPT
Answer
Add the following to the worker's js:
And it's solved.