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

CORS issue when using Custom (OpenAI Compatible) #158

Open
withsmilo opened this issue Dec 5, 2024 · 7 comments
Open

CORS issue when using Custom (OpenAI Compatible) #158

withsmilo opened this issue Dec 5, 2024 · 7 comments

Comments

@withsmilo
Copy link

Hi, I'm trying to register our customized OpenAI endpoint with Smart Composer. However, I met a CORS issue in my case.

https://<OUR_CUSTOM_ENDPOINT_URL>/chat/completions' from origin 'app://obsidian.md' has been blocked by CORS policy: Request header field x-stainless-os is not allowed by Access-Control-Allow-Headers in preflight response.

How can I address this issue? As far as I know, Copilot for Obsidian provides a way to enable CORS in their UI. (https://www.obsidiancopilot.com/en/docs/settings#adding-custom-models)
Thanks.

@glowingjade
Copy link
Owner

Are you using Ollama to run the model, or are you employing another method? If you're using Ollama, you can select "Ollama" as the model, and it will handle the CORS issue automatically.

However, if that's not the case, perhaps it's time for us to consider adding a CORS handling option for custom models as well.

@withsmilo
Copy link
Author

@glowingjade , thanks for quick reply.
Sadly, I'm not using Ollama, but using a custom OpenAI compatible model in my case. I would be more than grateful if you could consider my case. Thanks.

@glowingjade
Copy link
Owner

@withsmilo We'll add a CORS handling option to address this issue. Thank you for bringing this to our attention.

@kevin-on
Copy link
Collaborator

kevin-on commented Dec 8, 2024

@withsmilo Could you share the model you're using? It will help with implementing the feature.

@rewse
Copy link

rewse commented Dec 10, 2024

I have the same issue with https://github.com/aws-samples/bedrock-access-gateway

Access to fetch at '<OPENAI_BASE_URL>/api/v1/chat/completions' from origin 'app://obsidian.md' 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’ve confirmed it works with curl.

@kevin-on
Copy link
Collaborator

kevin-on commented Dec 13, 2024

@rewse Thanks for reporting. I will also test for amazon bedrook.

@ericmjl
Copy link

ericmjl commented Jan 10, 2025

Confirming that I have the same issue on my side. CORS with OpenAI-compatible API endpoint. We In my case, I'm seeing the following, with API endpoints obscured:

Access to fetch at 'https://<BASE_URL>/openai/v1/chat/completions' from origin 'app://obsidian.md' has been blocked by CORS policy: Request header field x-stainless-os is not allowed by Access-Control-Allow-Headers in preflight response.

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

No branches or pull requests

5 participants