bazarr icon indicating copy to clipboard operation
bazarr copied to clipboard

WIP / RFC: Enable CORS headers

Open sandervankasteel opened this issue 2 years ago • 8 comments

As discussed with @morpheus65535 over Discord. Currently this is preliminary PR and RFC for enabling / disabling CORS headers.

This allows browsers to execute cross-domain traffic between their 'domain' (ie. domain1.tld) and the 'domain' Bazarr is running on (192.168.1.1)

When the setting is enabled it will set the HTTP header Access-Control-Allow-Origin to * (IE, everyone). By default the setting this is disabled.

More background information on CORS headers: https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS

sandervankasteel avatar Jun 07 '22 20:06 sandervankasteel

This PR is currently in draft because I need to finish up on the testing.

sandervankasteel avatar Jun 07 '22 20:06 sandervankasteel

Looks good but don't add flask-cors to requireents.txt unless it require compiling on client computer. If it's pure python, vendor it in libs directory and make sure to add it to version.txt.

morpheus65535 avatar Jun 10 '22 01:06 morpheus65535

Looks good but don't add flask-cors to requireents.txt unless it require compiling on client computer. If it's pure python, vendor it in libs directory and make sure to add it to version.txt.

Thanks for your preliminary. I will change this and then continue onward with the testing :smile:

sandervankasteel avatar Jun 10 '22 18:06 sandervankasteel

@morpheus65535 I've started to continue working on this PR. But I had one question, how do I vendor the flash-cors dependency?

sandervankasteel avatar Jul 19 '22 19:07 sandervankasteel

@morpheus65535 I've started to continue working on this PR. But I had one question, how do I vendor the flash-cors dependency?

Sorry for the delay, I was on vacation.

You can simply put that directory (https://github.com/corydolphin/flask-cors/tree/master/flask_cors) inside libs directory.

morpheus65535 avatar Jul 26 '22 15:07 morpheus65535

This will enable cors only at restart, simple enable setting will do nothing. I will add some note about that fact

halali avatar Jul 26 '22 19:07 halali

@morpheus65535 I've started to continue working on this PR. But I had one question, how do I vendor the flash-cors dependency?

Sorry for the delay, I was on vacation.

You can simply put that directory (https://github.com/corydolphin/flask-cors/tree/master/flask_cors) inside libs directory.

@morpheus65535 I hope you enjoyed your holiday! Thanks for your reply, I will do that.

This will enable cors only at restart, simple enable setting will do nothing. I will add some note about that fact

@halali I also made a mention of that in the UI. Source: https://github.com/morpheus65535/bazarr/pull/1868/files#diff-2e987b2ddc76e1053aaf36788a3f14d4dbf315110727e2daf358de9a45a06315R125

sandervankasteel avatar Jul 26 '22 21:07 sandervankasteel

@morpheus65535 I've started to continue working on this PR. But I had one question, how do I vendor the flash-cors dependency?

Sorry for the delay, I was on vacation.

You can simply put that directory (https://github.com/corydolphin/flask-cors/tree/master/flask_cors) inside libs directory.

@morpheus65535 I hope you enjoyed your holiday! Thanks for your reply, I will do that.

This will enable cors only at restart, simple enable setting will do nothing. I will add some note about that fact

@halali I also made a mention of that in the UI. Source: https://github.com/morpheus65535/bazarr/pull/1868/files#diff-2e987b2ddc76e1053aaf36788a3f14d4dbf315110727e2daf358de9a45a06315R125

Sorry, missed that

halali avatar Jul 26 '22 21:07 halali

@morpheus65535 it's ready for review. Sorry for the delay, real life got in the way :)

sandervankasteel avatar Aug 21 '22 18:08 sandervankasteel

I added one single comment. Other than that, it looks really good, thanks!

morpheus65535 avatar Aug 22 '22 12:08 morpheus65535

@morpheus65535 No problem! And thank you for the review :)

sandervankasteel avatar Aug 22 '22 18:08 sandervankasteel