CORS and user authorization are different controls
A browser refusal does not prove the API key is wrong or the model is offline. It can mean the request architecture is inappropriate for a private account credential. A backend proxy must still restrict who can submit tasks, which model and cost they may approve, and who may retrieve each output.
What to do next
- 01
Move the provider call
Create a server-only route in your application that loads the credential privately. Do not accept a free-form upstream URL or forward arbitrary browser headers.
- 02
Add application ownership checks
Authenticate your own user and load their approved internal task. Persist the returned AISwapLab job ID against that user before allowing status or download access.
- 03
Test both paths
Verify the backend's read-only /models connection first, then test the browser-to-your-backend request using fixtures for generation states. Remove the exposed key from any earlier client build.
A concrete example
Illustrative design: a web page calls /api/my-generation on its own site. That route validates the signed-in user and approved credit ceiling, then calls AISwapLab server-side. The browser receives a safe task status rather than the account credential.
Before you call it ready
- The secret stays server-side.
- The proxy is authenticated and constrained.
- No browser security setting is weakened.
When to stop or choose another method
If a third-party widget requires a permanent account key in browser JavaScript, do not integrate it unchanged. Choose a server-side adapter or a different supported architecture.
