mirror of
https://git.rwth-aachen.de/acs/public/villas/node/
synced 2025-03-09 00:00:00 +01:00
add CORS headers for HTTP API responses
This commit is contained in:
parent
982136508b
commit
db5b8fc8cc
1 changed files with 9 additions and 0 deletions
|
@ -124,10 +124,19 @@ int api_http_protocol_cb(struct lws *wsi, enum lws_callback_reasons reason, void
|
|||
const char headers[] = "HTTP/1.1 200 OK\r\n"
|
||||
"Content-type: application/json\r\n"
|
||||
"User-agent: " USER_AGENT "\r\n"
|
||||
"Access-Control-Allow-Origin: *\r\n"
|
||||
"Access-Control-Allow-Methods: GET, POST, OPTIONS\r\n"
|
||||
"Access-Control-Allow-Headers: Content-Type\r\n"
|
||||
"Access-Control-Max-Age: 86400\r\n"
|
||||
"\r\n";
|
||||
|
||||
web_buffer_append(&s->response.headers, headers, sizeof(headers)-1);
|
||||
lws_callback_on_writable(wsi);
|
||||
|
||||
/* Only HTTP POST requests wait for body */
|
||||
if (lws_hdr_total_length(wsi, WSI_TOKEN_POST_URI) == 0)
|
||||
s->completed = true;
|
||||
|
||||
break;
|
||||
|
||||
case LWS_CALLBACK_CLOSED_HTTP:
|
||||
|
|
Loading…
Add table
Reference in a new issue