generativefm / generative.fm

A platform for playing generative music in the browser.
https://generative.fm
MIT License
1.59k stars 86 forks source link

CORS problem #38

Closed LawlietZe closed 5 years ago

LawlietZe commented 5 years ago

When I play the music, it shows:

Access to fetch at 'https://samples.generative.fm/index.1.5.0.json' from origin 'http://localhost:9999' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.

alexbainter commented 5 years ago

Hi @LawlietZe, this was done intentionally to help with costs, traffic recently increased quite a bit: Screenshot from 2019-03-19 09-43-26

I had always intended to setup a method of fetching the files locally during development but just hadn't gotten around to it yet. Hopefully I can get that added this week; I'll use this issue to track the work. Thanks!

LawlietZe commented 5 years ago

@metalex9 thank you !

alexbainter commented 5 years ago

See the readme for updated instructions!

alexbainter commented 5 years ago

Also see https://github.com/generative-music/generative.fm/issues/48, not sure why I didn't just do it this way from the beginning.

imyhxy commented 5 years ago

@metalex9 Hi, thanks for your awesome works. I still can't figure out how to run the generative.fm locally. I have pull the samples.generative.fm and built the samples but still got the CROS error when I tried to play the music.

alexbainter commented 5 years ago

@imyhxy Any chance you're not hosting the site at localhost? For now, you must access the site at localhost:<some port> for this to work, though I have a change sitting in the develop branch which will fetch local samples for any host other than my production and staging hosts.

Otherwise, ensure your directory for samples.generative.fm is directly adjacent to the directory for generative.fm. If the build process can't find the local sample files, a message is output before webpack's output when you run npm start or npm run build which will show you where it's looking for sample files.

imyhxy commented 5 years ago

@metalex9 Yes, I deployed the code to another computer on the LAN.

My workaround is to copy the whole public folder from samples.generative.fm into generative.fm. And change the DEFAULT_ENDPOINT in node_modules/@generative-music/samples.generative.fm/browser-client.js to public . Now it works.😋