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 Policy Error on File Upload After Upgrading to Reflex 0.6.7 #4613

Open
cbiqih opened this issue Jan 9, 2025 · 2 comments
Open

CORS Policy Error on File Upload After Upgrading to Reflex 0.6.7 #4613

cbiqih opened this issue Jan 9, 2025 · 2 comments

Comments

@cbiqih
Copy link

cbiqih commented Jan 9, 2025

Describe the bug
Error uploading files via 'rx.upload' : Access to XMLHttpRequest at 'http://localhost:8000/_upload' from origin 'http://localhost:3000' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.

To Reproduce
Steps to reproduce the behavior:

rx.upload(
    rx.flex(
        rx.button("Select file", ),
        rx.text("Drag and drop file here or click button to select file"),
        align='center',
        justify='center',
        spacing='3',
        direction="column",
    ),
    id="import_lexicon_file",
    padding="5em",
    accept={
        "text/csv": [".csv"],
        "text/tab-separated-values": [".tsv"]
    },
    on_drop=SelectFileDialogState.handle_upload(
        rx.upload_files(upload_id="import_lexicon_file")
    ),
    border_radius='1em',
    auto_focus=False,
    max_size=2 * 1024 * 1024, # 2MB
)

Expected behavior
In version 0.6.5, the development can upload files normally, but after the recent upgrade to 0.6.7, this error occurs, I hope to fix it as soon as possible.

Screenshots
Snipaste_2025-01-09_12-28-09

Specifics (please complete the following information):

  • Python Version: 3.13.0
  • Reflex Version: 0.6.7
  • OS: macOS 15.2 (24C101)
  • Browser (Optional): Chrome 131.0.6778.265 (x86_64)

Additional context
no

Copy link

linear bot commented Jan 9, 2025

@cbiqih
Copy link
Author

cbiqih commented Jan 9, 2025

The solution given by 'Ask AI' to add cors_allowed_origins was not valid:

import reflex as rx

config = rx.Config(
    app_name="myapp",
    cors_allowed_origins=["http://localhost:3000"],
)

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

1 participant