Skip to content

Instantly share code, notes, and snippets.

@marckrenn
Last active August 1, 2018 20:36
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save marckrenn/2bb78853e02af90c5904100a15398abe to your computer and use it in GitHub Desktop.
Save marckrenn/2bb78853e02af90c5904100a15398abe to your computer and use it in GitHub Desktop.
Update by Steve Ruiz
Utils.CORSproxy = (url) ->
# Detect local IPv4/IvP6 addresses
# https://stackoverflow.com/a/11327345
regexp = /(^127\.)|(^192\.168\.)|(^10\.)|(^172\.1[6-9]\.)|(^172\.2[0-9]\.)|(^172\.3[0-1]\.)|(^::1$)|(^[fF][cCdD])/
if regexp.test(window.location.hostname)
return "http://#{window.location.host}/_server/proxy/#{url}"
return url
@marckrenn
Copy link
Author

marckrenn commented Jul 26, 2017

else could also fall back to https://crossorigin.me/#{url} but that's probably too much magic …

EDIT: crossorigin.me isn't reliable enough for my taste

@aswinckr
Copy link

aswinckr commented Jun 18, 2018

Hi marckreen. your solution works like magic.. can you help me understand what does http://#{window.location.host}/_server/proxy/#{url} do exactly?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment