mirror of
https://github.com/meshtastic/firmware.git
synced 2025-04-23 09:06:02 +00:00
fix cors for meshtasticd to allow use of cross origin clients (#5463)
This commit is contained in:
parent
502a83bb8a
commit
601d912c6f
@ -232,9 +232,9 @@ int handleAPIv1ToRadio(const struct _u_request *req, struct _u_response *res, vo
|
||||
ulfius_add_header_to_response(res, "X-Protobuf-Schema",
|
||||
"https://raw.githubusercontent.com/meshtastic/protobufs/master/meshtastic/mesh.proto");
|
||||
|
||||
if (req->http_verb == "OPTIONS") {
|
||||
if (strcmp(req->http_verb, "OPTIONS") == 0) {
|
||||
ulfius_set_response_properties(res, U_OPT_STATUS, 204);
|
||||
return U_CALLBACK_CONTINUE;
|
||||
return U_CALLBACK_COMPLETE;
|
||||
}
|
||||
|
||||
byte buffer[MAX_TO_FROM_RADIO_SIZE];
|
||||
@ -269,6 +269,11 @@ int handleAPIv1FromRadio(const struct _u_request *req, struct _u_response *res,
|
||||
ulfius_add_header_to_response(res, "X-Protobuf-Schema",
|
||||
"https://raw.githubusercontent.com/meshtastic/protobufs/master/meshtastic/mesh.proto");
|
||||
|
||||
if (strcmp(req->http_verb, "OPTIONS") == 0) {
|
||||
ulfius_set_response_properties(res, U_OPT_STATUS, 204);
|
||||
return U_CALLBACK_COMPLETE;
|
||||
}
|
||||
|
||||
uint8_t txBuf[MAX_STREAM_BUF_SIZE];
|
||||
uint32_t len = 1;
|
||||
|
||||
@ -493,7 +498,9 @@ PiWebServerThread::PiWebServerThread()
|
||||
// Maximum body size sent by the client is 1 Kb
|
||||
instanceWeb.max_post_body_size = 1024;
|
||||
ulfius_add_endpoint_by_val(&instanceWeb, "GET", PREFIX, "/api/v1/fromradio/*", 1, &handleAPIv1FromRadio, NULL);
|
||||
ulfius_add_endpoint_by_val(&instanceWeb, "OPTIONS", PREFIX, "/api/v1/fromradio/*", 1, &handleAPIv1FromRadio, NULL);
|
||||
ulfius_add_endpoint_by_val(&instanceWeb, "PUT", PREFIX, "/api/v1/toradio/*", 1, &handleAPIv1ToRadio, configWeb.rootPath);
|
||||
ulfius_add_endpoint_by_val(&instanceWeb, "OPTIONS", PREFIX, "/api/v1/toradio/*", 1, &handleAPIv1ToRadio, NULL);
|
||||
|
||||
// Add callback function to all endpoints for the Web Server
|
||||
ulfius_add_endpoint_by_val(&instanceWeb, "GET", NULL, "/*", 2, &callback_static_file, &configWeb);
|
||||
|
Loading…
Reference in New Issue
Block a user