Mastermindzh / tidal-hifi

The web version of Tidal running in electron with hifi support thanks to widevine.
Other
912 stars 54 forks source link

Add cors to the express api #401

Closed Mjokfox closed 1 month ago

Mjokfox commented 1 month ago

Ive been trying to use the api, but couldnt get it working except in the browser for some reason. Adding cors to the api made it work on my end.

Mastermindzh commented 1 month ago

Whilst CORS in and of itself isn't a bad feature it probably shouldn't be added because something didn't work for you 😄. Can you explain what didn't work? Maybe I can help a bit.

Other than that, adding CORS is a good idea, I'll look into it. I would want it behind settings so that people can actually change the origins.

Mjokfox commented 1 month ago

So I've made a plugin for Vencord that shows what I'm current listening as my discord status. And i am using this api to get that. So i do a basic get request to http://localhost:47836/current. This works just fine when i do it in a basic nodejs environment. But with the exact same code in the plugin, it returns 'TypeError: Failed to fetch', apparently this is a CORS problem. I've tried plenty of headers with no avail. I thought since i had issues with it, others may too.

Mastermindzh commented 1 month ago

Alright, don't know Vencord but it makes sense if you're doing it from another app that CORS might be implemented there.

I probably have time in the weekend to add the settings and release a new version 😄

Mastermindzh commented 1 month ago

It was my bad mate... the API is already restricted to localhost so no need for settings. I will merge your PR.

PS: I did remove package-lock from your PR 😄

sonarcloud[bot] commented 1 month ago

Quality Gate Passed Quality Gate passed

Issues
0 New issues
0 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
No data about Duplication

See analysis details on SonarCloud