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

enhance: allow origins is regexp string #1817

Closed
wants to merge 2 commits into from
Closed

enhance: allow origins is regexp string #1817

wants to merge 2 commits into from

Conversation

smithyj
Copy link
Contributor

@smithyj smithyj commented Apr 22, 2022

allow origins is regexp string,need check origin is trusted

@smithyj
Copy link
Contributor Author

smithyj commented Apr 23, 2022

@kevwan

@kevwan kevwan self-requested a review April 23, 2022 14:26
@kevwan
Copy link
Contributor

kevwan commented Apr 23, 2022

Would you please add unit test and some details on this PR to describe the scenarios?

@smithyj
Copy link
Contributor Author

smithyj commented Apr 24, 2022

我们的前端域名有很多,而且子域名也有很多,还有不同的端口,比如:

test.baidu.com
three.test.baidu.com
other.baidu.com:4838
...

这种情况下,现有的 cors 组件就有问题了,一个个填写会很麻烦,所以得支持正则表达式,直接将根域名进行信任

@Issues-translate-bot
Copy link

Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑‍🤝‍🧑👫🧑🏿‍🤝‍🧑🏻👩🏾‍🤝‍👨🏿👬🏿


We have a lot of front-end domains, and also a lot of subdomains, and different ports, such as:

test.baidu.com
three.test.baidu.com
other.baidu.com:4838
...

In this case, there is a problem with the existing cors components, and it will be very troublesome to fill in one by one, so you have to support regular expressions and directly trust the root domain name

@smithyj
Copy link
Contributor Author

smithyj commented Apr 24, 2022

@kevwan see see

@kevwan
Copy link
Contributor

kevwan commented Apr 25, 2022

if strings.HasSuffix(origin, o) {
    return true
}

Should work like a charm.

1 similar comment
@kevwan
Copy link
Contributor

kevwan commented Apr 25, 2022

if strings.HasSuffix(origin, o) {
    return true
}

Should work like a charm.

@kevwan
Copy link
Contributor

kevwan commented Apr 25, 2022

Duplicate of #1827

@kevwan kevwan closed this Apr 25, 2022
@kevwan kevwan marked this as a duplicate of #1827 Apr 25, 2022
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

Successfully merging this pull request may close these issues.

3 participants