Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit678a477

Browse files
HTTPUpdateServer Allow external POSTS (CORS) (#6824)
* HTTPUpdateServer Allow external POSTS (CORS)* Format Updates - POST HTTPUpdateServerCo-authored-by: Joseph Francis <joefran@us.ibm.com>
1 parent9668f77 commit678a477

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

‎libraries/ESP8266HTTPUpdateServer/src/ESP8266HTTPUpdateServer-impl.h‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,24 @@ void ESP8266HTTPUpdateServerTemplate<ServerType>::setup(ESP8266WebServerTemplate
5959
_server->send_P(200,PSTR("text/html"), serverIndex);
6060
});
6161

62+
// handler for the /update form page - preflight options
63+
_server->on(path.c_str(), HTTP_OPTIONS, [&](){
64+
_server->sendHeader("Access-Control-Allow-Headers","*");
65+
_server->sendHeader("Access-Control-Allow-Origin","*");
66+
_server->send(200,F("text/html"),String(F("y")));
67+
},[&](){
68+
_authenticated = (_username == emptyString || _password == emptyString || _server->authenticate(_username.c_str(), _password.c_str()));
69+
if(!_authenticated){
70+
if (_serial_output)
71+
Serial.printf("Unauthenticated Update\n");
72+
return;
73+
}
74+
});
75+
6276
// handler for the /update form POST (once file upload finishes)
6377
_server->on(path.c_str(), HTTP_POST, [&](){
78+
_server->sendHeader("Access-Control-Allow-Headers","*");
79+
_server->sendHeader("Access-Control-Allow-Origin","*");
6480
if(!_authenticated)
6581
return _server->requestAuthentication();
6682
if (Update.hasError()) {

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp