mnakada / atomcam_tools

Hack tool for atomcam and wyzecam.
Other
183 stars 22 forks source link

CORS error on get_jpeg.cgi #53

Closed thematrixdev closed 2 years ago

thematrixdev commented 2 years ago

I am embedding the camera image onto Home-Assistant. It shows a CORS error:

Access to XMLHttpRequest at 'https://atom.mydomain.com/cgi-bin/get_jpeg.cgi' from origin 'https://webserver.mydomain.com' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource.

May you add the header on get_jpeg.cgi page?

Thanks.

mnakada commented 2 years ago

Please modify as follows.

/var/www/cgi-bin/get_jpeg.cgi

#!/bin/sh

echo "Cache-Control: no-cache"
echo "Content-Type: image/jpeg"
echo "Access-Control-Allow-Origin: *"
echo ""
echo jpeg -n | /usr/bin/nc localhost 4000