Error Cross origin requests are only supported for HTTP when loading a local file

0 votes

I'm trying to load a 3D model into Three.js with JSONLoader, and that 3D model is in the same directory as the entire website.

I'm getting the error as 

 "Cross origin requests are only supported for HTTP." 

 but I don't know what's causing it nor how to fix it?

Jun 8, 2020 in Java-Script by kartik
• 37,510 points
1,872 views

1 answer to this question.

0 votes

Hii @kartik,

You are loading the model using either file:// or C:/, which stays true to the error message as they are not http://

So you can either install a webserver in your local PC or upload the model somewhere else and use jsonp and change the url to:

http://example.com/path/to/model.

So even though your file originates from the same host (localhost), but as long as the scheme is different (http / file), they are treated as different origin.

Hope it helps!

answered Jun 8, 2020 by Niroj
• 82,780 points

Related Questions In Java-Script

0 votes
1 answer

Why are preload link not working for JSON requests ?

Hii @kartik, You have to add as="fetch" for JSON files. ...READ MORE

answered Jun 19, 2020 in Java-Script by Niroj
• 82,780 points
1,700 views
0 votes
1 answer

jQuery AJAX fires error callback on window unload - how do I filter out unload and only catch real errors?

Hello, In the error callback or $.ajax you have three ...READ MORE

answered Apr 27, 2020 in Java-Script by Niroj
• 82,780 points
2,523 views
0 votes
1 answer

Error:React-router urls don't work when refreshing or writing manually

Hello @kartik, You can change your .htaccess file and insert ...READ MORE

answered Apr 27, 2020 in Java-Script by Niroj
• 82,780 points
7,542 views
+1 vote
1 answer

How to make anchor tag with routing using Laravel?

Hey @kartik, First you have to go to ...READ MORE

answered Mar 18, 2020 in Laravel by Niroj
• 82,780 points
15,453 views
0 votes
1 answer

What is redirection in Laravel?

Named route is used to give specific ...READ MORE

answered Mar 18, 2020 in Laravel by Niroj
• 82,780 points
1,752 views
0 votes
1 answer

How to install Laravel via composer?

Hello, This is simple you just need to ...READ MORE

answered Mar 23, 2020 in Laravel by Niroj
• 82,780 points
1,448 views
+1 vote
1 answer

What are named routes in Laravel and How can specify route names for controller actions?

Hey @kartik, Named routing is another amazing feature of ...READ MORE

answered Mar 23, 2020 in Laravel by Niroj
• 82,780 points
21,214 views
0 votes
1 answer

How to implement useEffect() so the list on the front page updates only when a name change has been detected?

Hello @kartik, Instead of passing the entire object ...READ MORE

answered Jun 1, 2020 in Java-Script by Niroj
• 82,780 points
322 views
webinar REGISTER FOR FREE WEBINAR X
Send OTP
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP