Support CORS - API

Discussions about RaZberry - Z-Wave board for Raspberry computer
Post Reply
peec2
Posts: 4
Joined: 09 Mar 2014 14:40

Support CORS - API

Post by peec2 »

Hey,

I noticed that CORS seems not to be supported so in chrome you get Access Origin Resource Sharing issues.

It can be solved with setting these headers:

header('Access-Control-Allow-Origin: *');
header('Access-Control-Allow-Methods: POST, GET, OPTIONS'); .. etc..

Is it possible to support CORS in anyway?

I like to run the web on another server

vwirus
Posts: 12
Joined: 25 Feb 2014 00:12

Re: Support CORS - API

Post by vwirus »

You can do it your own with proxy server - nginx, or in node.js. Ths is temporairy solution.

peec2
Posts: 4
Joined: 09 Mar 2014 14:40

Re: Support CORS - API

Post by peec2 »

Thanks for the idea, i am already using haproxy actually for my home net servers. Used haproxy to proxy the 8083 port. Now running the home-automation software in Apache on another production server :)

Heres the config if anyone is going to use the same:

Code: Select all


backend pi_http
       server pi 10.0.0.100:8083

frontend homeautomation
       mode http
       bind *:8083
       default_backend pi_http




User avatar
PoltoS
Posts: 5824
Joined: 26 Jan 2011 19:36

Re: Support CORS - API

Post by PoltoS »

With which URL do you experience whis?

With new automation API we have it:
automation/request.js: this.responseHeader('Access-Control-Allow-Methods', 'GET,PUT,POST,DELETE');

Post Reply