Skip to content

Conversation

@Mateusz-Dobrzynski
Copy link
Member

Resolves #73

explicitly define allowed methods and origins
@Mateusz-Dobrzynski Mateusz-Dobrzynski self-assigned this Sep 24, 2025
@Mateusz-Dobrzynski Mateusz-Dobrzynski added the bug Something isn't working label Sep 24, 2025
@Mateusz-Dobrzynski Mateusz-Dobrzynski linked an issue Sep 24, 2025 that may be closed by this pull request
Copy link
Member

@jakubmanczak jakubmanczak left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't like it being mandatory for local development, as most of the time you'd just specify 'localhost' anyway; this, or request origin reflection, should happen in dev builds by default.

let layer = CorsLayer::new()
.allow_origin(frontend_origin.parse::<HeaderValue>().unwrap())
.allow_methods([Method::GET, Method::POST, Method::DELETE, Method::PATCH])
.allow_headers([CONTENT_TYPE])
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wait, does it require us to specify allowed headers? Please tell me it doesn't. And let's not do that if we can avoid it.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sadly, it does.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you tell me exactly why? How does this need manifest?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When trying to make requests at browser level, errors are returned: this one and others relating to it. This forced me to define allowed origins, methods and headers.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After testing this turns out to be true; I meant specifically Allowed-Headers, since the other ones are commonly seen and all. This is so extremely dumb. But yes, I concede. This works.

Copy link
Member

@jakubmanczak jakubmanczak left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd still have a think about that CORS origin reflection, but this will have to do.

@jakubmanczak jakubmanczak merged commit fe03997 into master Oct 9, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Modify CORS to allow including credentials

3 participants