WebThingsIO / webthing-upy

MicroPython implementation of a Web Thing server
MIT License
56 stars 16 forks source link

403 Forbidden Request forbidden #17

Closed gerisse closed 4 years ago

gerisse commented 5 years ago

hi i did in my esp32 heltec : i have the good messages :+1:

start.thing() (...)INFO:sparkfun_esp32_thing:starting the server INFO:server:Starting Web Server on port 80

but Firefox says : 403 Forbidden Request forbidden -- authorization will not help an idea ? Thanks

mrstegeman commented 5 years ago

403 is only ever returned by the server is you try to access it via the wrong hostname/IP address. It appears that you must access it via one of the following:

brianpeiris commented 5 years ago

I ran into this issue as well. If I'm not mistaken, the problem is that the validateHost function attempts to retrieve the "host" header, when actually the header name is case sensitive and is actually "Host", with a capital "H".

https://github.com/mozilla-iot/webthing-upy/blob/33f5b0d11d02ada50022187e2614d08c39925bcb/webthing/server.py#L267

mrstegeman commented 5 years ago

In the MicroWebSrv source, it looks like headers are all normalized: https://github.com/loboris/MicroPython_ESP32_psRAM_LoBo/blob/c9b9dd184e698bd77ff4fa50ad8564e2258fb4e8/MicroPython_BUILD/components/micropython/esp32/modules/microWebSrv.py#L453

Is that not working as it should?

brianpeiris commented 5 years ago

Hmm, you're right, microWebSrv.py in the rest-improvements fork of MicroPython does indeed lower case its headers:

https://github.com/dhylands/MicroPython_ESP32_psRAM_LoBo/blob/rest-improvements/MicroPython_BUILD/components/micropython/esp32/modules/microWebSrv.py#L454

In retrospect, I think I ran into this issue when I mistakenly attempted to use the official micropython firmware instead of building and running the rest-improvements version. So, disregard my previous comment.

Thanks.