D
D
Denis Krylov2021-02-08 16:48:24
Nginx
Denis Krylov, 2021-02-08 16:48:24

Fix cors error using client side nginx?

Good afternoon.
There is a certain closed site used in our stores, which is hosted outside the local network and there are DVRs that are naturally located in the local network. I'm trying to implement the task: when certain actions are performed on the site, a special xml file is sent to the DVR

function sendNVR()
  {
var xml = 
"<?xml version: '1.0' encoding='utf-8'?><VideoOverlay><normalizedScreenSize><normalizedScreenWidth>704</normalizedScreenWidth>                <normalizedScreenHeight>576</normalizedScreenHeight></normalizedScreenSize><attribute><transparent>false</transparent>        <flashing>false</flashing></attribute><fontSize>1</fontSize><TextOverlayList><TextOverlay><id>1</id><enabled>true</enabled><displayText>text1</displayText><positionX>20</positionX><positionY>500</positionY></TextOverlay><TextOverlay><id>2</id><enabled>true</enabled><displayText>text2</displayText></TextOverlay></TextOverlayList></VideoOverlay>";
var xhr = new XMLHttpRequest();
    xhr.open("PUT", 'http://admin:[email protected]/ISAPI/System/Video/inputs/channels/1/overlays', true);
.
I ran into a CORS error: "...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."

For myself, I see a solution to add the missing header using Ngnix. Two days of monitoring the Internet gave a bunch of options for this option, but using the server side. Since I'm not strong in ngnix, can anyone tell me how to implement this using ngnix on the client side using this site? Various chrome extensions did not help.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey Sokolov, 2021-02-08
@sergiks

Maybe you can make some URL on the site that will give the correct CORS headers, and accept XML, which will immediately, already from the server (which does not care about CORS), go to the video recorders.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question