nginx設置跨域 --copy的 親測有效 有興趣的小夥伴可以試下

        add_header Access-Control-Allow-Credentials true;
        add_header Access-Control-Allow-Origin $http_origin;
        location / {
            root   /web/www/Leslie/public;
            index  index.html index.htm index.php;
            if ($request_method = 'OPTIONS') {
                add_header Access-Control-Allow-Origin $http_origin;
                add_header Access-Control-Allow-Methods $http_access_control_request_method;
                add_header Access-Control-Allow-Credentials true;
                add_header Access-Control-Allow-Headers $http_access_control_request_headers;
                add_header Access-Control-Max-Age 1728000;
                return 204;
             }
            if (-e $request_filename) {
                break;
             }
             if (!-e $request_filename) {
                 rewrite ^/(.*)$ /index.php/$1 last;
                  break;
               }
                #
        }

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章