Motion - Support Question 2017x 03x 21x 080028

Access-Control-Allow-Origin

Question

motion.conf on thread1.conf:

videodevice /dev/video0 text_left CAMERA 1 target_dir /home/pi/webcam/camera1 stream_port 9061 stream_auth_method 1 stream_authentication video0:sHs9061abc

Call with XMLHttpRequest :

var url = "http://10.16.1.65:9061/stream.mjpeg"; var method = "POST"

var xhr = new XMLHttpRequest ();

xhr.open(method, url, true); xhr.withCredentials = true; xhr.setRequestHeader("Authorization", 'Basic ' + btoa('video0:sHs9061abc')); xhr.send();

Error Output on Console :

XMLHttpRequest cannot load http://10.16.1.65:9061/stream.mjpeg. Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'file://' is therefore not allowed access. The response had HTTP status code 501.

Please give me solution, Thanks
motion.conf on thread1.conf:
------------------------------------
videodevice /dev/video0
text_left CAMERA 1
target_dir /home/pi/webcam/camera1
stream_port 9061
stream_auth_method 1
stream_authentication video0:sHs9061abc

Call with XMLHttpRequest :
----------------------------------
var url = "http://10.16.1.65:9061/stream.mjpeg";
var method = "POST"

var xhr = new XMLHttpRequest(); 
        
xhr.open(method, url, true);
xhr.withCredentials = true;
xhr.setRequestHeader("Authorization", 'Basic ' + btoa('video0:sHs9061abc'));             
xhr.send();


Error Output on Console :
-------------------------------
XMLHttpRequest cannot load http://10.16.1.65:9061/stream.mjpeg. Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'file://' is therefore not allowed access. The response had HTTP status code 501.

Environment

Motion version: 3.2.12
ffmpeg version:  
Libraries: ffmpeg, mysql, postgresql
Server OS: Raspbian Jessie
-- SuburSubekti - 21 Mar 2017

Answer

Topic revision: r1 - 21 Mar 2017, SuburSubekti
Copyright © 1999-2017 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Please do not email Kenneth for support questions (read why). Use the Support Requests page or join the Mailing List.
This website only use harmless session cookies. See Cookie Policy for details. By using this website you accept the use of these cookies.