if you do not set 'allowedOrigins' in app settings than all domains will be allowed to use CORS (Access-Control-Allow-Origin = "*")
However, the if statement that allows this logic did not work because there was always at least one string in the origins array (an empty one, if 'allowedOrigins' is not set).
Therefore, I've added a Where LINQ clause that ensures that no empty strings end up in this array, meaning that the if statement is hit and it does apply the default behaviour of allowing all origins.
I have tested this all with Content manager 9.3. CORS requests from any domain are now able to succeed when 'allowedOrigins' is not set or has an empty value, and specific domains can still be allowed as well if that is what is required.
Hey @dchurchland is there any chance this PR can be merged? If not, I will close/abandon the PR as I really don't want to leave this lingering around if it'll never get merged.
Hey there,
I set out to use this CORS module for the Content Manager Service API but found that there was a problem with it.
In the readme it states that:
However, the if statement that allows this logic did not work because there was always at least one string in the origins array (an empty one, if 'allowedOrigins' is not set).
Therefore, I've added a Where LINQ clause that ensures that no empty strings end up in this array, meaning that the if statement is hit and it does apply the default behaviour of allowing all origins.
I have tested this all with Content manager 9.3. CORS requests from any domain are now able to succeed when 'allowedOrigins' is not set or has an empty value, and specific domains can still be allowed as well if that is what is required.