最近fork了大佬一个页面,但是因为用到了 vue 而我暂时又不会写,控制台报 cors 不出内容很捉急。
因为这个只是一个单页面显示文档的东西,就不去找大佬们解决了。
google 了一圈找到最快的解决方案。
Lets's GO!
nginx 配置
直接在 sites-enabled/example.com.conf 配置
server
{
listen 80;
listen [::]:80;
server_name example.com;
location / {
index index.html index.htm index.php;
root /home/wwwroot/;
add_header Access-Control-Allow-Origin *;
add_header Access-Control-Allow-Credentials true;
}
}
最重要的就是 allow-origin 那句话。
好了,现在 systemctl reload nginx 就能打开了。
其它 nginx 自己按需添加哦。
Post : 20220226
评论区