damonwonghv / youtube-search-api

Get Youtube Search result without any login or api key
MIT License
86 stars 30 forks source link

CORS ? #21

Closed jamenai closed 1 year ago

jamenai commented 1 year ago

image

I try to use the api from a local small webapp but ran in cors issues.

Whats wrong? ;-)

thorn117 commented 1 year ago

The api does not work in the browser due to cors restrictions from YouTube (the browser checks the cross-origin headers, which are obviosly not valid for your app). You could wrap it in your own rest api (express, nestjs, ...)

jamenai commented 1 year ago

Nice, thank you for the quick answer!

damonwonghv commented 1 year ago

Tested and did some research already, it's hard to prevent CORS in a production environment, but you can use a clientside proxy to bypass it when development, after you built it may not work.