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

请问如何解除跨域? #50

Open
vitaminx opened this issue May 9, 2023 · 3 comments
Open

请问如何解除跨域? #50

vitaminx opened this issue May 9, 2023 · 3 comments

Comments

@vitaminx
Copy link

vitaminx commented May 9, 2023

我想用 Url-Shorten-Worker 作为 https://github.com/youshandefeiyang/sub-web-modify 的短链接服务,在调用 api 的过程中一直报错:
youshandefeiyang/sub-web-modify#31

sub-web-modify 作者说需要解除跨域,请问如何设置?试了很多网上的方法都不行!

@xyTom
Copy link
Owner

xyTom commented May 18, 2023

默认情况下应该是允许跨域请求的

具体配置位置如下,on代表开启cors标头,允许来自任何域名的浏览器跨域请求:

cors: "on",//Allow Cross-origin resource sharing for API requests.

实现跨域功能的代码如下:

if (config.cors=="on"){
response_header={
"content-type": "text/html;charset=UTF-8",
"Access-Control-Allow-Origin":"*",
"Access-Control-Allow-Methods": "POST",
}
}

@vitaminx
Copy link
Author

我试试看能否设置成功

@crazypeace
Copy link

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