1.安装PM2管理器
打开宝塔面板的 软件商店
搜索 PM2管理器
,点击安装等待安装完成。
2.下载安装proxy
在终端内打开 /www/wwwroot/
目录,使用 git clone https://github.com/Rob--W/cors-anywhere.git
进行下载。
如果下载慢可以用其它工具下载好了之后上传到目录,然后安装。
3.PM2管理器安装项目
到软件商店中打开PM2管理器,按照下图所示填写。
4.映射域名
映射域名后记得添加解析记录和SSL。
5.测试
访问我们映射的域名,如果显示以下字样证明搭建跨域服务成功。
如果访问不成功请尝试放行8080端口。
This API enables cross-origin requests to anywhere.
Usage:
/ Shows help
/iscorsneeded This is the only resource on this host which is served without CORS headers.
/<url> Create a request to <url>, and includes CORS headers in the response.
If the protocol is omitted, it defaults to http (https if port 443 is specified).
Cookies are disabled and stripped from requests.
Redirects are automatically followed. For debugging purposes, each followed redirect results
in the addition of a X-CORS-Redirect-n header, where n starts at 1. These headers are not
accessible by the XMLHttpRequest API.
After 5 redirects, redirects are not followed any more. The redirect response is sent back
to the browser, which can choose to follow the redirect (handled automatically by the browser).
The requested URL is available in the X-Request-URL response header.
The final URL, after following all redirects, is available in the X-Final-URL response header.
To prevent the use of the proxy for casual browsing, the API requires either the Origin
or the X-Requested-With header to be set. To avoid unnecessary preflight (OPTIONS) requests,
it's recommended to not manually set these headers in your code.
Demo : https://robwu.nl/cors-anywhere.html
Source code : https://github.com/Rob--W/cors-anywhere/
Documentation : https://github.com/Rob--W/cors-anywhere/#documentation
6.使用方法
https://cors.xxx.com/https://跨域源
评论已关闭