AlarmDecoder-WebApp & CORS
Posted: Mon Apr 25, 2016 8:31 am
I have an AD2Pi and just setup the web app using the complete rasbian image. Everything seems to work ok until i try to go to this page:
https://192.168.3.23/static/swagger/index.html
I get this message and the request for the alarmdecoder.json fails due to CORS, Access-Control-Allow-Origin not being set:
I figured it would be an easy change in nginx and added the CORS headers in the @alarmdecoder location with no luck. Any help would be appreciated.
https://192.168.3.23/static/swagger/index.html
I get this message and the request for the alarmdecoder.json fails due to CORS, Access-Control-Allow-Origin not being set:
Can't read from server. It may not have the appropriate access-control-origin settings.
This API Documentation assumes you are on your local network. To control and test the API through swagger, you must be on your local network. The default address assumes you can resolve the domain alarmdecoder.local - if you cannot, please input the IP address of your AD2PI Network Appliance. (ex: http://192.168.1.100:5000/static/alarmdecoder.json) - or download bonjour for windows Here to resolve the broadcasted alarmdecoder.local domain.
I figured it would be an easy change in nginx and added the CORS headers in the @alarmdecoder location with no luck. Any help would be appreciated.
- Code: Select all
location @alarmdecoder {
proxy_pass http://127.0.0.1:5000;
include uwsgi_params;
uwsgi_param UWSGI_SCHEME $scheme;
uwsgi_param SERVER_SOFTWARE nginx/$nginx_version;
if ($request_method = OPTIONS) {
add_header Access-Control-Allow-Origin "*";
add_header Access-Control-Allow-Methods "GET, POST, PUT, PATCH, OPTIONS";
add_header Access-Control-Allow-Headers "*";
add_header Access-Control-Allow-Credentials true;
add_header Content-Length 0;
add_header Content-Type text/plain;
add_header Access-Control-Max-Age 1728000;
return 200;
}
add_header Access-Control-Allow-Origin *;
add_header Access-Control-Allow-Credentials false;
add_header Access-Control-Allow-Headers "Content-Type, Accept, Authorization, Origin, User-Agent";
add_header Access-Control-Allow-Methods "GET, POST, PUT, PATCH, OPTIONS";
proxy_redirect off;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Host $server_name;
proxy_set_header X-Scheme $scheme;
proxy_set_header Access-Control-Allow-Origin '*';
proxy_redirect http://localhost:5000 http://$host;
}