Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No 'Access-Control-Allow-Origin' header is present on the requested resource. #49

Open
FilJed opened this issue Feb 12, 2024 · 1 comment

Comments

@FilJed
Copy link

FilJed commented Feb 12, 2024

Hi!

I have my own openai compatible endpoint that works fine in all my programs
i.e. in python:

import openai
client = openai.OpenAI(
    api_key="my-key",
    base_url="http://***.111:80/v1"
)
with open("./tracks/test.ogg", "rb") as audio_file:
    transcript = client.audio.transcriptions.create(
        file = audio_file,
        model = "whisper-1",
        response_format="srt",
    )
print(transcript)

So endpoint works fine.

But when I try to put it as API_URL I keep getting network error message in logs

Access to XMLHttpRequest at 'http://***111/v1/audio/transcriptions' from origin 'app://obsidian.md' 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.

Thing that confuses me is the error message contain no port info. Is it normal?

I've tried putting all cersions:

  • http://***.111:80/v1/audio/transcriptions
  • http://***.111:80/v1
  • http://***.111:80
    Non of them proved to be working

I saw in other issues (i.e. #2) that changing endpoint works well.
What I'm doing wrong?

@JungeWerther
Copy link

JungeWerther commented Oct 5, 2024

Yeah thanks, this solved my issue. If your custom openai compatible endpoint is in nodeJS, for example, add CORS to your response headers like:

new Response(
    JSON.stringify(data),
    { headers: { 
      "Content-Type": "application/json",
      "Access-Control-Allow-Origin": "*", // or specify a particular origin
     } })

might make a difference.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants