侧边栏壁纸
博主头像
奇楠木语博主等级

行动起来,活在当下

  • 累计撰写 138 篇文章
  • 累计创建 94 个标签
  • 累计收到 1 条评论

目 录CONTENT

文章目录

nginx解决网页cors报错(单页面急速解决方案)

Administrator
2022-02-26 / 0 评论 / 0 点赞 / 188 阅读 / 1039 字

最近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

0

评论区