File tree 1 file changed +16
-0
lines changed
libraries/ESP8266HTTPUpdateServer/src
1 file changed +16
-0
lines changed Original file line number Diff line number Diff line change @@ -59,8 +59,24 @@ void ESP8266HTTPUpdateServerTemplate<ServerType>::setup(ESP8266WebServerTemplate
59
59
_server->send_P (200 , PSTR (" text/html" ), serverIndex);
60
60
});
61
61
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
+
62
76
// handler for the /update form POST (once file upload finishes)
63
77
_server->on (path.c_str (), HTTP_POST, [&](){
78
+ _server->sendHeader (" Access-Control-Allow-Headers" , " *" );
79
+ _server->sendHeader (" Access-Control-Allow-Origin" , " *" );
64
80
if (!_authenticated)
65
81
return _server->requestAuthentication ();
66
82
if (Update.hasError ()) {
You can’t perform that action at this time.
0 commit comments