Laravel / NGINX-通过NGINX添加的响应标头将响应返回为404

时间:2019-07-29 12:41:57

标签: laravel nginx http-response-codes

我目前正在开发一个充当CDN(不带N)的小平台,我已经向NGINX conf中添加了响应头以允许跨源资源共享;

location / {

    if ($request_method ~* "(GET|POST)") {
      add_header "Access-Control-Allow-Origin"  "*" always;
    }

    if ($request_method = OPTIONS ) {
      add_header "Access-Control-Allow-Origin"  *;
      add_header "Access-Control-Allow-Methods" "GET, POST, OPTIONS, HEAD";
      add_header "Access-Control-Allow-Headers" "Authorization, Origin, X-Requested-With, Content-Type, Accept";
      return 200;
    }

    try_files $uri $uri/ /index.php?$query_string;
}

location = /favicon.ico { access_log off; log_not_found off; }
location = /robots.txt  { access_log off; log_not_found off; }

除了我设置用于传递正在生成的css和js文件的两条路径之外,哪条路径还可以工作。内容在那里,但仅返回404。

enter image description here

我尝试强制使用状态码,但无济于事;

enter image description here

任何帮助将不胜感激。

0 个答案:

没有答案