Skip to content
This repository has been archived by the owner on Nov 13, 2024. It is now read-only.

[Bug] CORS preflight headers - OPTIONS method not allowed #284

Open
2 tasks done
coreation opened this issue Feb 9, 2024 · 0 comments
Open
2 tasks done

[Bug] CORS preflight headers - OPTIONS method not allowed #284

coreation opened this issue Feb 9, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@coreation
Copy link
Contributor

Is this a new bug?

  • I believe this is a new bug
  • I have searched the existing issues, and I could not find an existing issue for this bug

Current Behavior

When calling the chat completions API endpoint directly from a client like the browser, it makes a preflight CORS check using the OPTIONS HTTP request. This is not supported and results in the API call failing as it does not get past this check.

Expected Behavior

Unless the API endpoint is solely intended for proxy-like clients that entirely control the HTTP calls and headers made, I would expect the OPTIONS HTTP request being supported. This makes it for browser application clients possible to directly interface with the exposed canopy API.

I believe the exposed API is not protected and if this is done intentionally, I'm glad to close the issue :)

Steps To Reproduce

  1. Run a vanilla set-up of canopy
  2. Send an OPTIONS request to the chat/completions endpoint

Relevant log output

INFO:     127.0.0.1:55991 - "OPTIONS /v1/qanda-content/chat/completions HTTP/1.1" 405 Method Not Allowed

Environment

n/a

Additional Context

No response

@coreation coreation added the bug Something isn't working label Feb 9, 2024
kowshik24 added a commit to kowshik24/canopy that referenced this issue Mar 11, 2024
…quests

This commit addresses the CORS issue reported in Issue pinecone-io#284, where the API failed to handle preflight OPTIONS requests, causing failures in direct client-to-API communications from browsers. The FastAPI application now includes CORSMiddleware, allowing proper handling of CORS preflight checks and enabling browser-based clients to directly interface with the Canopy API.

Changes:
- Added CORSMiddleware to the FastAPI application setup.
- Configured the middleware to allow all origins, methods, and headers, facilitating cross-origin requests.

This update ensures better accessibility and integration capabilities of the Canopy API for various client applications, especially those running in browser environments.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant