宝塔Nginx设置跨域访问-跨域_解决无法引用

浅染
2024-12-28发布 /正在检测是否收录...

为什么设置跨域?

有时候不设置跨域网站图片,视频,字体,等一系列文件会出现无法访问或引用的情况,比如新搭建的图床引用的图片、视频等失败显示错误

1.选择 允许 跨域的网站,选择设置,配置文件。


配置文件


2.增加允许跨域访问配置。

add_header Access-Control-Allow-Origin *;
add_header Access-Control-Allow-Headers Origin,Accept,Authorization,platformId,ut,DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type;
add_header Access-Control-Allow-Methods GET,POST,OPTIONS;
add_header Access-Control-Allow-Credentials true;

配置


3.保存后关闭网站,重启nginx


原文:
https://blog.csdn.net/qq_24118445/article/details/136609743

喜欢就支持一下吧
点赞 0 分享 赞赏
评论 抢沙发
OωO
取消