CORS issue with ShapeDiver API

CORS_error_LI

With the CORS extension, I could avoid the issue to fetch the data from ShapeDiver server, but without it, I cannot successfully fetch the data.

Is it related with the following change across Chromium projects?

I tried to find a way which is proper way to handle it, such as editing the code as recommended, but ShapeDiver API request is done in new SDVApp.ParametricViewer(settings).

I could not dig in the request, such as editing the Request headers… Is there any way to edit the API request more in detail, rather than change the parameter through settings?

I hope it is clear for you to understand the issue.

We don’t allow port 8000 in general, 8080 should work. If you are trying to embed a model you also need set up domains correctly, similar issue has been resolved in this Forum post:

More on whitelisting domains in the Documentation:

If you have issues with external files or custom environments, see the Documentation pages below for details:

Hi Pavol,

Thanks for your reply! I also tried with port 8080, but the issue is still there.

Regarding whitelist, I was already aware of it, so, anytime I use ShapeDiver API, I added the domain name with/without port number in the list. So, it does not help this issue neither.

However, I have installed allow CORS policy in the Browser, and it solved the issue. But it is not desirable because it relies on external Extension for using API.

Is there any other suggestion to solve this CORS issue in better way?

You don’t need any extensions to embed ShapeDiver models successfully. Can you double-check that:

  1. You set up the global domains correctly
  2. You enabled them in model settings

We allow port 8080 for local testing and it should just work. Could you give me more details what are you trying to do? Link to your model and web site where you want to embed it would help a lot.

Okay, I set up the global domains correctly. That is why how I can see the model successfully with Extension, which is mentioned in the earlier post.

From localhost, port 8080, 8000 both worked. But I host the application in AWS instance and I accessed it via URL of this instance, I could not get data via Shape Diver API. The web application is perfectly loaded and could see it, but the ShapeDiver viewer part is still loading and cannot fetch data.

More precisely, access to AWS instance → Nginx (Docker container) → Node JS Application(Docker container) calls Shape Diver API. Again, this worked in localhost environment. And it works with allow CORS extension. It cannot fetch data in AWS instance.

Hope you have heard or known the similar issues…

We need a bit more information to get to the bottom of this. Could you

  1. open the browser console in Chrome
  2. go to network tab
  3. search for “ticket”
  4. and post the “Preview” of the response you receive, something like this:

Sure.

Fail to get response, and failed to see Preview of it.

Maybe header information might be more helpful.
Error one from AWS instance:

No Error, I got response, too. from localhost:8000

We have configured CORS to allow the loopback address (127.0.0.1) for local testing, but general IP addresses are not allowed. Please use a hostname which resolves to your IP address.

What do you mean with “Please use a hostname which resolves to your IP address”?

Once I map this IP address to domain name, it will be allowed again? Or Is there certain range of IP address which are allowed for ShapeDiver API, except (127.0.0.1)?

I mean please use a host name https://your.host.name instead of an IP address https://1.2.3.4

1 Like

Thanks for keep following the question! it worked in the end :slight_smile:

1 Like