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 Allow origin #1117

Open
Nicobas opened this issue Apr 3, 2023 · 2 comments
Open

CORS Allow origin #1117

Nicobas opened this issue Apr 3, 2023 · 2 comments

Comments

@Nicobas
Copy link

Nicobas commented Apr 3, 2023

Hi!

My api I generate signed links for download/upload files. When I use these links from my front-end in Vue.js I get CORS errors telling me that the origin is not the right one. fake-gcs-server is running with docker on localhost:8001 and my front-end on localhost:1234. In the code of this project there seems to be an "Access-Control-Allow-Origin: *" rule but it doesn't work. How can I authorize my front end to acces to these ressources?

This is my docker compose config :

  storage:
    container_name: b4m-storage
    image: fsouza/fake-gcs-server:1.44
    volumes:
      - ./.tmp/storage_data:/storage
    ports:
      - "8081:8081"
    command: ["-scheme", "http", "-port", "8081", "-external-url", "http://localhost:8081", '-public-host', "localhost:8081"]

Thanks

@fsouza
Copy link
Owner

fsouza commented May 2, 2023

Hmm, that should work. Can you provide more details on the error you get from the frontend?

@psigen
Copy link

psigen commented Jan 3, 2024

I am getting the same error in my frontend. Here is the full line from my browser:

Access to XMLHttpRequest at 'http://localhost:8000/my-files/uploads/287f2dc8-82fe-4c9f-9bc9-5679c6860dfc/ZmVhdHVyZXR5cGUuU1RM?X-Goog-Algorithm=GOOG4-RSA-SHA256&X-Goog-Credential=[...]&X-Goog-Date=20240103T042045Z&X-Goog-Expires=3600&X-Goog-SignedHeaders=host&X-Goog-Signature=[...]' from origin 'http://localhost:5173' 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.

I am testing with the options:

["-external-url", "http://localhost:8000", "-public-host", "localhost:8000", "-scheme", "both"]

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

3 participants