nginx配置允许单个域名跨域访问Access-Control-Allow-Origin
Tofloor
poster avatar
张强890627
deepin
2020-04-14 03:12
Author
大家好:
        在本地测试了下前后端分离的配置方法,下面记录了些测试结果(网上找了些没成功)。
测试环境:
firefox:70.0.1
chrome:78.0.3904.97
nginx:1.16.1
vue:2.x

  1. add_header Access-Control-Allow-Origin *;
  2. add_header Access-Control-Allow-Origin http://localhost:8080;

  3. add_header Access-Control-Allow-Origin http://localhost:*;
  4. add_header Access-Control-Allow-Origin http://localhost;
  5. add_header Access-Control-Allow-Origin localhost:8080;
  6. add_header Access-Control-Allow-Origin localhost
Copy the Code
以空行为界,上面的配置可行(第一行允许所有、第二行允许单个)、下面不行。


Reply Favorite View the author
All Replies

No replies yet