Skip to content

[help] Access-Control-Allow-Credentials: true, Access-Control-Allow-Origin cannot be *, but I did not find the corresponding implementation #117

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

Closed
rentiansheng opened this issue Aug 6, 2021 · 4 comments

Comments

@rentiansheng
Copy link

rentiansheng commented Aug 6, 2021

If ajax wants to carry cookies when sending cross-domain requests, the withcredentials attribute of the request object must be set to true.

At this time, the server response header Access-Control-Allow-Origin cannot be * (asterisk), it must be a whitelist style, that is, which URLs must be allowed to access, except for the response header Access-Control-Allow-Origin Setting, you must also set another response header: Access-Control-Allow-Credentials: true.

	if c.allowCredentials {
                 // TODO:Missing settings for Access-Control-Allow-Origin, when AllowedOrigins=*
		headers.Set("Access-Control-Allow-Credentials", "true")
	}
@rentiansheng rentiansheng reopened this Aug 6, 2021
@rentiansheng rentiansheng changed the title [help] cors needs to carry cookies, but I did not find the corresponding implementation [help] Access-Control-Allow-Credentials: true, Access-Control-Allow-Origin cannot be *, but I did not find the corresponding implementation Aug 6, 2021
@rs
Copy link
Owner

rs commented Aug 6, 2021

See #57

@rs rs closed this as completed Aug 6, 2021
@rentiansheng
Copy link
Author

Can we abstract the Access-Control-Allow-Origin value as an adapter, the default is to use the current behavior, and also allow users to customize their own behavior, in the test environment, the source here is a bit complicated. @rs

@rs
Copy link
Owner

rs commented Aug 9, 2021

You can use AllowOriginFunc and always return true.

@rentiansheng
Copy link
Author

You can use AllowOriginFunc and always return true.
If this is AllowedOrigins=[""], the returned Access-Control-Allow-Origin=, not the value of Access-Control-Allow-Origin is not the origin url address in the actual request

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants