Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save name-k/8080390 to your computer and use it in GitHub Desktop.
Save name-k/8080390 to your computer and use it in GitHub Desktop.
Allow Cross-Domain Images with CORS Images are usually cool to serve from a different domain but if you want access to their data with canvas, you're in trouble. This snippet allows you to get raw image data via canvas:
<IfModule mod_setenvif.c>
<IfModule mod_headers.c>
<FilesMatch "\.(cur|gif|ico|jpe?g|png|svgz?|webp)$">
SetEnvIf Origin ":" IS_CORS
Header set Access-Control-Allow-Origin "*" env=IS_CORS
</FilesMatch>
</IfModule>
</IfModule>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment