Hi everyone,
I’m running into a CORS issue while trying to make a fetch request to the OpenAI API from my local development server. Here’s the error I’m getting:
“Access to fetch at ‘…api.openai.com…’ has been blocked by CORS policy: 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’m working on a project running on localhost:5000, and I’m trying to call the OpenAI API. Has anyone encountered this before? How can I resolve this issue? I’ve heard about setting the mode to no-cors, but I’m not sure if that’s the right solution since I need the response data. Any advice or workarounds would be greatly appreciated!
Thanks in advance!
Thank you for your advice. I’m calling an API to generate an ephemeral token, then using RTCPeerConnection to connect to https://api.openai.com/v1/realtime with that ephemeral token. It was working fine yesterday, but when I checked again today, the error I described above appeared
I encountered the same error today. That CORS error made my existing apps stop working . The app is built of reactjs + capacitors and WebRTC realtime is used. I really don’t know why fetch request does not work when requesting /v1/realtime endpoint to get SDP. Even though it works when requesting /v1/realtime/sessions endpoint to retrieve EPHEMERAL_KEY. Very strange, isn’t it ? Can any one from Open AI team please have a look ? Thank you very much in advance
Here is an update. I already tried to send sdp and ephemeral token to nodejs endpoint where it requested open ai realtime endpoint to retrieve SDP. but it did not work either. it returned an error from Cloudflare security page saying
Sorry, you have been blocked
You are unable to access transceiver .api . openai. com …
It seems an issue with Cloudflare
No sadly it did not work for me. I just downloaded and test that openAI realtime console demo running on localhost:3000 . it used to work before, but not today