arkhipenko / esp32-mjpeg-multiclient-espcam-drivers

ESP32 MJPEG Multiclient Streaming Server with latest Espressif drivers
BSD 3-Clause "New" or "Revised" License
167 stars 40 forks source link

CrossOrigin request headers #20

Closed ansonl closed 1 year ago

ansonl commented 1 year ago

Hi,

Is there a way to add CORS request headers to allow the webcam to a embedded on another page? I tried server.sendHeader("Access-Control-Allow-Origin", "*"); and server.enableCrossOrigin(true); but it doesn't seem to be sending the correct headers because the code currently uses the WifiClient client object to send data and I can't find a premade way to change the WifiClient header.

ansonl commented 1 year ago

Turns out it was Chrome blocking private network requests by default now. It can be turned off at chrome://flags/#block-insecure-private-network-requests.

I also added the following headers to JHEADER and HEADER variables in case other clients have issues

"Access-Control-Allow-Private-Network: true\r\n" \
"Access-Control-Allow-Origin: *\r\n" \
"Access-Control-Allow-Credentials: true\r\n" \