Home > Mobile >  check if an external url exists. cors-react
check if an external url exists. cors-react

Time:03-09

I am working locally with react and a nodejs server. I have configured my nodejs server to communicate with react and it works.

From react I want to check if external urls (for example youtube) exist, but the cors error always jumps.

I have tried with axios, XMLHttpRequest, fetch and I have used the header : 'Access-Control-Allow-Origin': '*',

I can remove the cors validation from the browser for testing, but what happens when I upload it to the server?

How can I check if an image, page, video... on an external server exists?

CodePudding user response:

CORS is only applied when you try to do it directly from your browser. Then you can create your own server, create an API endpoint to check if a URL exists, and then, from your react page, you send requests to your API and your API check the page existence. – (by Pipe)

  • Related