When a cross-domain request interface is required, it will appear
been blocked by CORS policy: No’Access-Control-Allow-Origin’ header is present on the requested resource.
It can be solved in code or directly in nginx
Similar to the code deployed by GOFLY under nginx
Just add the header header
add_header Access-Control-Allow-Origin * ; add_header Access -Control-Allow-Methods ' GET, POST, OPTIONS ' ;
server{ listen 80 ; server_name gofly.sopans.com; access_log / var /log/nginx/ gofly.sopans.com.access.log main; location / static { root / var /www/html/go-fly; // Own deployment path } location / { add_header Access -Control-Allow-Origin * ; add_header Access -Control-Allow-Methods ' GET, POST, OPTIONS ' ; proxy_pass http: // 127.0.0.1:8081; proxy_http_version 1.1 ; proxy_set_header X -Real- IP $remote_addr; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection " upgrade " ; proxy_set_header Origin "" ; } }
Read More:
- [Solved] configure: error: udev support requested but libudev header not installed
- Solve the problem of 404 Not Found error in nginx accessing dynamic interface
- Solution of device eth0 does not see to be present, delaying initialization. Error in network card under Linux
- Push to origin/Master was rejected [How to Solve]
- [Solved] ERROR: The kernel module failed to load, because it was not signed by a key that is trusted by the
- [Nginx] solution: it can’t be accessed on the background API interface after HTTPS (access the specified port through the domain name)
- ls: cannot access /com: Host is down
- Git Push Error: error: RPC failed; HTTP 413 curl 22 The requested URL returned error: 413
- Nginx Startup Error: Job for nginx.service failed because the control process exited with error code
- [Solved] Job for network.service failed because the control process exited with error code. See “systemctl st
- [Solved] FTP Setup Error: Job for vsftpd.service failed because the control process exited with error code…
- [Solved] Nginx cannot access pictures on FTP Error: Whitelabel error page
- Nginx configuration 80 can be accessed by forcing jump 443 or not
- [Solved] SSH Error: ECDSA host key for xxx has changed and you have requested strict checking.
- [Solved] websocket: the client is not using the websocket protocol: ‘upgrade’ token not found in ‘Connection’ head
- [Solved] Raspberry Pi Error: VNC error “No configured security type is supported by 3.3 VNC Viewer“
- Virtual machine failed to start network service error: ob for network.service failed because the control process exited with error code
- [Solved] Linux WebService Startup Error: BindException: Cannot assign requested address
- [Solved] WSUS client access server exception error – 0x8024401f
- Nginx realizes the same background service for portal and business