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

[Feature Request] Plugin for CORS #146

Open
Gerben-T opened this issue Nov 7, 2024 · 0 comments
Open

[Feature Request] Plugin for CORS #146

Gerben-T opened this issue Nov 7, 2024 · 0 comments
Labels
type: feature New feature or request

Comments

@Gerben-T
Copy link

Gerben-T commented Nov 7, 2024

Describe the problem/motivation

From my zebar page i'm trying to contact an API. This API doesn't support CORS.
The API expects some custom headers for authorization.
I'm using JS fetch() to communicate with the API.

This results in a CORS error:

XXX from origin 'http://asset.localhost' 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. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.

When using the mode: no-cors in the fetch options the error disappears, but the API returns a 403 because the "browser" strips almost all headers (see https://developer.mozilla.org/en-US/docs/Web/API/RequestInit#no-cors)

The only way to solve this is by some sort of "cors-anywhere" proxy, but i couldn't find a way to start a node process automatically with my zebar config.

I found this Tauri plugin which should solve this issue: https://github.com/idootop/tauri-plugin-cors-fetch but since we can't add plugins ourselves i started this issue.

Describe the solution you'd like

Either:

Alternatives considered

Running my own "cors-anywhere" node proxy. This works but i want this to auto start when my zebar config starts, so i don't have to do that manually.

Ideally this should not even be necessary if there is a tauri plugin that can solve this.

@Gerben-T Gerben-T added the type: feature New feature or request label Nov 7, 2024
@github-project-automation github-project-automation bot moved this to 📬 Needs triage in zebar Nov 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: feature New feature or request
Projects
Status: 📬 Needs triage
Development

No branches or pull requests

1 participant