Skip to content
Fix Code Error

“Cross origin requests are only supported for HTTP.” error when loading a local file

March 13, 2021 by Code Error
Posted By: Anonymous

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 "Cross origin requests are only supported for HTTP." error, but I don’t know what’s causing it nor how to fix it.

Solution

My crystal ball says that 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

Origin is defined in RFC-6454 as

   ...they have the same
   scheme, host, and port.  (See Section 4 for full details.)

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.

Answered By: Anonymous

Related Articles

  • Ball to Ball Collision - Detection and Handling
  • React client tries to access server resource without…
  • Tkinter understanding mainloop
  • 'parcel' is not recognized as an internal or…
  • 'No JUnit tests found' in Eclipse
  • Crystal Reports 13 And Asp.Net 3.5
  • c++ "Incomplete type not allowed" error accessing…
  • Can anyone explain what JSONP is, in layman terms?
  • How to prevent scrolling the whole page?
  • What is JSONP, and why was it created?
  • How to use PrimeFaces p:fileUpload? Listener method…
  • Unknown difference between logic of OOP code…
  • XMLHttpRequest cannot load ✘✘✘ No…
  • Unity color wont assign to ball or what it should be…
  • Upload video files via PHP and save them in…
  • Use external scripts inside a Polymer element
  • How to set up file permissions for Laravel?
  • Apache server keeps crashing, "caught SIGTERM,…
  • Setting PHP tmp dir - PHP upload not working
  • Three.js: Cannot display mesh created with texture array
  • Exception in Tkinter callback,TypeError: unsupported…
  • How do I install Java on Mac OSX allowing version switching?
  • What is Common Gateway Interface (CGI)?
  • render function or template not defined in…
  • How do I include certain conditions in SQL Count
  • Can someone explain how to implement the jQuery File…
  • Crystal Reports for VS2012 - VS2013 - VS2015 -…
  • How do SO_REUSEADDR and SO_REUSEPORT differ?
  • How do I customize results from vaadin-upload…
  • Can't upload files with Apollo-client GraphQL in…
  • How to remove MySQL completely with config and…
  • How do I connect to this localhost from another…
  • Upload a file to Amazon S3 with NodeJS
  • How do I set the conditional requirements and how do…
  • Elasticsearch does not return jsonp
  • ExpressJS How to structure an application?
  • Unity Measuring Real distance between two object
  • Incorporate JQuery-file-upload to application
  • How to query an ssdp server using java
  • Polymer 1.0, how to pass down attributes to another…
  • How to integrate SAP Crystal Reports in Visual Studio 2017
  • Loading cross-domain endpoint with AJAX
  • parsing JSONP $http.jsonp() response in angular.js
  • VueJS CKeditor5 upload images
  • Pass array and/or object data between Polymer elements
  • paintComponent() not being called
  • Specifying $.ajax JSONP Callback Name in Zepto
  • Postgres could not connect to server
  • File upload with ember-upload, how to fill request…
  • Upload Image to MySQL with nodejs and multer
  • How to create a game over screen for a basic HTML/JS game?
  • Default initialization of member variables or add…
  • Error message "Forbidden You don't have permission…
  • Error in using "vaadin file upload"(polymer) via…
  • Smart way to truncate long strings
  • center images with each other in logo carousel
  • How do I upload FIle in Vuejs and Expressjs
  • CKEditor Upload Adapter Sends [object Promise] to Server
  • How to solve No 'Access-Control-Allow-Origin' in…
  • FileReader upload File through Ember Data
  • Crystal Reports - Adding a parameter to a 'Command' query
  • How to enable Google Play App Signing
  • How to upload a file in Django?
  • File upload with el-upload and axios, no progress bar
  • The definitive guide to form-based website authentication
  • How to upload image in CodeIgniter?
  • How to create and publish a Vuejs component on NPM
  • What does "Could not find or load main class" mean?
  • XMLHttpRequest cannot load file. Cross origin…
  • What's the best way of scraping data from a website?
  • Google Forms file upload complete example
  • json Uncaught SyntaxError: Unexpected token :
  • How to update Python?
  • How to write "Html.BeginForm" in Razor
  • Simple C example of doing an HTTP POST and consuming…
  • Vuejs function with multiple data
  • Runing vue/cli app under docker simple index.html is opened
  • IIS URL Rewrite and Web.config
  • coercing to Unicode: need string or buffer, NoneType…
  • How can I visualize an API mashup in Postman?
  • vue express uploading multiple files to amazon s3
  • Ember.js ember-data and cross-domain ajax requests
  • Aurelia passing data into bindable value of template
  • How can you force the UI to update in the middle of…
  • problem with client server unix domain stream…
  • Route undefined when importing in Laravel excel
  • Upload file from VueJS app to API in Laravel
  • “Origin null is not allowed by…
  • Ukkonen's suffix tree algorithm in plain English
  • How do I return the response from an asynchronous call?
  • Visual Studio debugging/loading very slow
  • Html ordered list 1.1, 1.2 (Nested counters and…
  • commandButton/commandLink/ajax action/listener…
  • Start redis-server with config file
  • Multiple Image Upload PHP form with one input
  • How to rotate a 3D object on axis three.js?
  • What are the undocumented features and limitations…
  • Logging best practices
  • How can I find the product GUID of an installed MSI setup?
  • PHP - Failed to open stream : No such file or directory

Disclaimer: This content is shared under creative common license cc-by-sa 3.0. It is generated from StackExchange Website Network.

Post navigation

Previous Post:

git: fatal: Could not read from remote repository

Next Post:

How to convert byte array to string

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

.net ajax android angular arrays aurelia backbone.js bash c++ css dataframe ember-data ember.js excel git html ios java javascript jquery json laravel linux list mysql next.js node.js pandas php polymer polymer-1.0 python python-3.x r reactjs regex sql sql-server string svelte typescript vue-component vue.js vuejs2 vuetify.js

  • you shouldn’t need to use z-index
  • No column in target database, but getting “The schema update is terminating because data loss might occur”
  • Angular – expected call-signature: ‘changePassword’ to have a typedeftslint(typedef)
  • trying to implement NativeAdFactory imports deprecated method by default in flutter java project
  • What should I use to get an attribute out of my foreign table in Laravel?
© 2022 Fix Code Error