How to enable 'Access-Control-Allow-Origin' header for all files in a directory of XAMPP?

后端 未结 2 1120
旧巷少年郎
旧巷少年郎 2021-02-12 11:30

I am developing a HTML5 Javascript app to get an image from my local server which runs on the same machine as the app. When I run the app on my Chrome, I got:

相关标签:
2条回答
  • 2021-02-12 11:54

    Create a file called ".htaccess" in the directory of your files and add the following to the file.

    Header set Access-Control-Allow-Origin "http://localhost:50000/"
    
    0 讨论(0)
  • 2021-02-12 12:05

    You need to create the .htaccess file first and put it on your root document of application and then set it at the beginning of the file

    Header set Access-Control-Allow-Origin *
    

    Cheers,

    0 讨论(0)
提交回复
热议问题