A tiny transparent proxy. The benefit: it adds the CORS-headers! Why? It prevents Cross Domain Errors.
Try it: http://corsify.me
- Without CORS-headers: http://shaky-library.surge.sh
- With CORS-headers aka "corsyfied": http://localhost:3001/http://shaky-library.surge.sh
Cross-origin resource sharing (CORS) is a mechanism that allows restricted resources (e.g. fonts) on a web page to be requested from another domain outside the domain from which the resource originated. https://en.wikipedia.org/wiki/Cross-origin_resource_sharing
Your script from http://rebel-mother.surge.sh makes an AJAX-request to http://shaky-library.surge.sh.
You see the infamous "XMLHttpRequest cannot load http://shaky-library.surge.sh. Origin http://rebel-mother.surge.sh is not allowed by Access-Control-Allow-Origin." error message.
Change your AJAX-Request from http://shaky-library.surge.sh to http://localhost:3001/http://shaky-library.surge.sh. Et voilá: no more errors.
For now: yes.
$ git clone https://github.com/martinkr/corsify.git the repository and fire up your own local instance with docker or plain node.js.
Fast and clean. No additional files on your machine.
- Build the image:
$ docker build -t corsify:latest . - Start the container:
$ docker run -p 3001:3000 corsify:latest - Go to: http://localhost:3001
Uses alpine:3.6 and node:8.4.0.
Fast and easy, but all those node_modules…
- Install dependencies
$ npm installor$ yarn - Build the files and start server
$ npm startor$ yarn start - Go to: http://localhost:3000
Requires nodejs. Recomended: v8.4.0, but it might work with older versions too.
- ECMAScript 2015 on
nodejs v8.4.0 - Rendering
Mustache v2.3.0templates - CSS 3 piped through
postcss-cli v4.1.1withcssnano v3.10.0andcssnano-preset-advanced v4.0.0-rc.2, - Running on
express`v4.14.1 - With
forever v0.15.3 - And gzip
compression v1.7.0 - 100% code coverage using
mocha v3.5.2,chai v4.1.2,supertest v3.0.0and"nyc 11.2.1",
- https://enable-cors.org
- https://en.wikipedia.org/wiki/Cross-origin_resource_sharing
- https://www.html5rocks.com/en/tutorials/cors
Licensed under the MIT license.
Copyright (c) 2016 - 2021 Martin Krause [email protected] http://martinkr.github.io