Blocked by CORS policy - No 'Access-Control-Allow-Origin'

Solved
Sagi_Green
Shopify Partner
6 1 0

Hi

I'm trying to fetch a very simple JSON from my private server from my storefront and I get this error when making an Ajax call. 

I'm building a vehicle parts store and my scenario is like this:

The user enters its vehicle number --> Ajax call to my server where I have a list of 3.5 million records of vehicles numbers and their models --> Ajax return a simple JSON with vehicle model code --> redirect the user to a collection page with this model code as a tag filter. 

What is the best way to do this scenario without facing the CORS error?

 

 

0 Likes

This is an accepted solution.

Hey,

Use CORS Anywhere. It's fantastic for this type of situation.
There is a demo plus further instructions in the link, additionally you can find some stuff on youtube about it.

Let me know how it goes.

Kind regards, 
Diego

◦ Problem Solved? ✔️ Please click on Accept as Solution and like.
◦ Using a free theme? Improve it with copy/paste code snippets clicking here.
◦ Looking to hire an experienced developer? Same day response: ezfycode@gmail.com.
Sagi_Green
Shopify Partner
6 1 0

Worked like a charm. 

Thank you so much, @diego_ezfy ! 

 

0 Likes
sadnewspanda
New Member
1 0 0

Support for cors-anywhere has been limited - so this solution is no longer valid.

Source:
https://github.com/Rob--W/cors-anywhere/issues/103

0 Likes