Check if we can access the template before using the CORS proxy #687
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
When loading a template, the current behavior is to check if the template URL's domain is on the safe hosts list (a list of websites that serve CORS headers that allow Pxls to load that template), and if it's not on the safe hosts list, use the CORS proxy.
This means that if a template that isn't on the safe hosts list serves CORS headers that allow Pxls to load it, it will still get proxied through the CORS proxy, even though we could load it directly.
This pull request adds a check where it sends a HEAD request to the template URL to see if it's allowed to load it, and if it is, then it doesn't use the CORS proxy.