龙空技术网

has been blocked by CORS policy_nginx解决跨域问题

一只爱笑的程序猿 182

前言:

现时看官们对“nginx禁止svn”大约比较关切,各位老铁们都想要学习一些“nginx禁止svn”的相关资讯。那么小编同时在网摘上收集了一些对于“nginx禁止svn””的相关知识,希望兄弟们能喜欢,小伙伴们快快来学习一下吧!

关于跨域的问题,是老生常谈了....这回又出现了...

不过这个跨域问题是可以在nginx中配置解决了:

直接看nginx.conf配置文件把:

下面的:

charset utf-8;

add_header Access-Control-Allow-Origin *;

add_header Access-Control-Allow-Headers Origin,X-Requested-Width,Content-Type,Accept;

这一部分就是用来解决跨域的

    server {        listen       8001;        server_name  localhost;charset utf-8;        add_header Access-Control-Allow-Origin *;        add_header Access-Control-Allow-Headers Origin,X-Requested-Width,Content-Type,Accept;        #charset koi8-r;        #access_log  logs/host.access.log  main; location / {	 root  D:/ALLSVN/ydy/YdyFront;        	 index  userLogin.html userLogin.htm;        } location /api {	 proxy_pass ;        }      location /login {	 proxy_pass ;        }	location /videoUrl {	 proxy_pass ;      	  }	location /img{		rewrite ^/img/(.*)$ /$1 break;		root D:/resource/upload/img;	}        #error_page  404              /404.html;        # redirect server error pages to the static page /50x.html        #        error_page   500 502 503 504  /50x.html;        location = /50x.html {            root   html;        }        # proxy the PHP scripts to Apache listening on 127.0.0.1:80        #        #location ~ \.php$ {        #    proxy_pass   ;        #}        # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000        #        #location ~ \.php$ {        #    root           html;        #    fastcgi_pass   127.0.0.1:9000;        #    fastcgi_index  index.php;        #    fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;        #    include        fastcgi_params;        #}        # deny access to .htaccess files, if Apache's document root        # concurs with nginx's one        #        #location ~ /\.ht {        #    deny  all;        #}    }

标签: #nginx禁止svn