I’m developing a Twitch integration for my company that will run in an embedded browser on the user’s local machine. During development, I’m hosting the application with a local web host (vite, if anyone is interested).
However, during development, whenever I make a request to the twitch API, I get the following CORS error:
Access to fetch at 'https://api.twitch.tv/helix/users' from origin 'http://localhost:5174' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.
I’ve seen previous issues on this forum and on Stack Overflow that were resolved by adding different headers, but I haven’t seen any issues related to the missing Access-Control-Allow-Origin header from the twitch servers.
The error in my original message was exactly what you said:
No 'Access-Control-Allow-Origin' header is present...
Chrome is complaining that helix doesn’t have an Access-Control-Allow-Origin header, and I’m wondering if other people are seeing the same error and what I can do to get around it.
Your site is hosted on an HTTPS server. Mine is hosted HTTP on localhost. I’m trying to confirm how to get it working on my development environment too.