How can I fix the error No 'Access-Control-Allow-Origin'?

Hello, how can I fix this error in the JS?
No 'Access-Control-Allow-Origin' header is present on the requested resource.
https://codepen.io/lycorp/pen/rJPopp - a link to the project!
I tried cors but why it does not work!
Can't fix it if you could help, I would be grateful)
June 7th 19 at 15:01
2 answers
June 7th 19 at 15:03
CORS will not work here, proxy the request through to the backend.
The nature of the error is that the resource from which request data is not provided the header for CORS.
Thank you)
But never heard of this, can you please throw a link to some documentation? - Lelia.Wunsch commented on June 7th 19 at 15:06
Yes the first few links from the search engine request "how does CORS" will help You. - Gonzalo.Hane39 commented on June 7th 19 at 15:09
Well I tried, didn't work, the error is in one Ms.)
It may be that you did wrong, but besides this error, there is no other) - Lelia.Wunsch commented on June 7th 19 at 15:12
I mean , I tried? Are you the owner of the domain and the website to which You send the request? If not, how have You tried? - Gonzalo.Hane39 commented on June 7th 19 at 15:15
So I wrote that tried cors, then I realized that without access to the website will not work!
Then you wrote (CORS will not work here, proxy the request through to the backend. )
So I ask how to proxy? - Lelia.Wunsch commented on June 7th 19 at 15:18
Look , if You dopolnyaet request on the website of JS it is executed in the browser of the visitor within Your site. Naturally when a request is sent directly (stupidly opened the link in browser tab) - then all will be revealed, but in order for Your site to have access via AJAX to another site - another site that needs to be resolved. This is done through the CORS headers the site that allows and asks data. Otherwise, you could put any website by posting an AJAX request on the popular online on another website and everyone who opened the page by - would make a request that would result in a small DoS attack. So to solve Your problem - You need to send a request to your back, which will form a common request moonwalk, wait for the answer and give it to the script of Your front. Because it turns out the proxy through Your back. - Gonzalo.Hane39 commented on June 7th 19 at 15:21
Easier even nginx to sponsirovat. - afton_Abbo commented on June 7th 19 at 15:24
can nginx proxy, does not matter, the main thing that directly from the visitor was not AJAX moonwalk, and went to You control the resource. - Gonzalo.Hane39 commented on June 7th 19 at 15:27
Thanks, I'll try) - Lelia.Wunsch commented on June 7th 19 at 15:30
yeah I know, was just voicing another option. It is sometimes easier. - afton_Abbo commented on June 7th 19 at 15:33
June 7th 19 at 15:05
First,
const moonURL = "http://moonwalk.cc/api/videos.json?";

replace
const moonURL = "https://moonwalk.cc/api/videos.json?";


And then have to communicate with the owners of the domain.
in order to get access, the process is too long!
To circumvent in any way? - Lelia.Wunsch commented on June 7th 19 at 15:08
can raise the server, for example, using curl to send requests from your site and return your site result. And there already want parsite on the server side, you want - on the client.
But in my opinion, it is easier to wait for processing of the access request. - Gonzalo.Hane39 commented on June 7th 19 at 15:11

Find more questions by tags Web Development