AlarmDecoder-WebApp & CORS

General Discussion

AlarmDecoder-WebApp & CORS

Postby brettahale » 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:
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;
    }
brettahale
newt
newt
 
Posts: 2
Joined: Sun Apr 24, 2016 10:29 am

Re: AlarmDecoder-WebApp & CORS

Postby kevin » Mon Apr 25, 2016 10:37 am

Hi,

Until we get this figured out in the webapp, you can view the API at http://www.alarmdecoder.com/swagger/
Not an employee of the company. Just here to help and keep things clean.
kevin
Platinum Nut
Platinum Nut
 
Posts: 994
Joined: Fri Aug 16, 2013 10:10 am

Re: AlarmDecoder-WebApp & CORS

Postby brettahale » Tue Apr 26, 2016 9:11 am

Cool, thanks for heads up!
brettahale
newt
newt
 
Posts: 2
Joined: Sun Apr 24, 2016 10:29 am

Re: AlarmDecoder-WebApp & CORS

Postby yhax » Wed Apr 11, 2018 5:47 pm

brettahale wrote:Cool, thanks for heads up!


Did you ever manage to get this working locally?
yhax
newt
newt
 
Posts: 7
Joined: Sat Jan 06, 2018 11:58 am

Re: AlarmDecoder-WebApp & CORS

Postby kevin » Thu Apr 12, 2018 8:13 pm

Kind of fell off the radar as low priority
Not an employee of the company. Just here to help and keep things clean.
kevin
Platinum Nut
Platinum Nut
 
Posts: 994
Joined: Fri Aug 16, 2013 10:10 am

Re: AlarmDecoder-WebApp & CORS

Postby miragejb » Thu Jul 08, 2021 12:16 pm

I'm having the same problems. When I click on the "REST API" link on the Advanced Topics -> Developer Resources page, I get the same message above. The link I am using is: https://www.alarmdecoder.com/swagger/

Is there another way I can read the REST API documentation since I can't access it through the website?

Thanks.
miragejb
Junior Nut
Junior Nut
 
Posts: 29
Joined: Wed Jan 17, 2018 7:32 am

Re: AlarmDecoder-WebApp & CORS

Postby kevin » Sun Jul 25, 2021 5:49 pm

miragejb wrote:I'm having the same problems. When I click on the "REST API" link on the Advanced Topics -> Developer Resources page, I get the same message above. The link I am using is: https://www.alarmdecoder.com/swagger/

Is there another way I can read the REST API documentation since I can't access it through the website?

Thanks.


In the explore box at the top, change the URL to https, ex:make_clickable_callback(MAGIC_URL_FULL, ' ', 'https://www.alarmdecoder.com/alarmdecoder.json', '', ' class="postlink"')
Not an employee of the company. Just here to help and keep things clean.
kevin
Platinum Nut
Platinum Nut
 
Posts: 994
Joined: Fri Aug 16, 2013 10:10 am


Return to General

Who is online

Users browsing this forum: No registered users and 8 guests

cron