0

I have some react js code, which if I embed it in my index.html works fine. But when I try to reference that code from an external .jsx file, it fails to access that code and throws an error. Please help.

This is how I am referencing the jsx file

<script type="text/jsx" src="autocomplete_js/custom_react.jsx">

These are the errors I get:

Resource interpreted as Script but transferred with MIME type text/plain: "file:///C:/react/autocomplete_js/custom_react.jsx"

XMLHttpRequest cannot load file:///C:/react/autocomplete_js/custom_react.jsx. Cross origin requests are only supported for protocol schemes: http, data, chrome, chrome-extension, https, chrome-extension-resource

user3422637
  • 3,967
  • 17
  • 49
  • 72

1 Answers1

1

Be sure to make your files be served by a web server (Apache or Ngnix).

I tried both, when files are served by Apache, it works like a charm, when directly opened in Chrome (no problem with Safari), I have the same error.

Blackus
  • 6,883
  • 5
  • 40
  • 51