CORS headers for accessing a file on another domain

后端 未结 1 447
清酒与你
清酒与你 2021-01-16 06:57

I am attempting to create an audio visualization program on Codepen. I have created my own Ubuntu web server with apache which allows me direct access to modify headers and

相关标签:
1条回答
  • 2021-01-16 07:42

    My first thought is that the problem is your

    Access-Control-Allow-Origin: *, *
    

    I don't think it is understanding the *, * thing. Try just *.

    Edit: you can check what the header really looks like with a command like this:

    curl -v -o /dev/null http://williamgreen.hopto.org/audioVisualization/song.mp3
    

    And, lo, it even works for me, yielding (among a lot of other headers):

    < Access-Control-Allow-Origin: *
    

    So that is hunky-dory.

    Second, are you running this from a file: origin? That doesn't work on Chrome (I thought it would work on Firefox, but maybe that's changed). You have to run it from an http: or https: origin.

    By "running from an file: origin" I mean, is the HTML file that is running that Javascript being loaded from an URL that beings with "file:". If so, that is not likely to work.

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