通过配置谷歌或nginx实现跨域访问
作者:ailion
发布时间:2022-07-28 10:14
1人已阅读
简介:

一、配置谷歌浏览器支持跨域

1、在C盘根目录下创建空文件夹 MyChromeDevUserData
image.png
2、复制一个谷歌浏览器快捷方式,右键打开属性在目标的地址栏最后加上 --disable-web-security --user-data-dir=C:\MyChromeDevUserData
image.png
3、打开浏览器
image.png

二、使用nginx实现跨域

1、下载nginx http://nginx.org/en/download.html
2、进入nginx根目录打开cmd 执行 start nginx.exe
image.png

1、start nginx.exe 启动
2、nginx -s reload 重启
3、nginx -s stop 停止

3、配置nginx.conf文件,进入conf文件夹用记事本打开nginx.conf文件

server { listen 8088; #监听端口 server_name 127.0.0.1; # 本机ip # location / { # 配置访问静态文件 # root D:/nginx-1.18.0/conf/opt/html; # index index.html index.htm; # } location / { # 访问为根路径 代理到本地服务 proxy_pass http://192.168.101.4:3005; } location /cas { 访问为/cas开头代理到服务端地址 proxy_pass http://192.168.101.2:3000/cas; } }

4、保存后重启 nginx -s reload

写下您的评论...
评论