Giter Site home page Giter Site logo

asagajda / cors-container Goto Github PK

View Code? Open in Web Editor NEW

This project forked from imjacobclark/cors-container

0.0 1.0 0.0 25 KB

A CORS proxy in a container (Docker) for when you need to `Access-Control-Allow-Origin: *`!

License: MIT License

Dockerfile 0.42% JavaScript 72.86% HTML 26.73%

cors-container's Introduction

cors-container

A CORS proxy in a container (Docker) for when you need to Access-Control-Allow-Origin: *!

Build Status

About

If you need permissive CORS for a front-end project, simply deploy this container and proxy your HTTP requests through it.

Once the container is running, you may navigate to http://container-address:3000/https://jacob.uk.com, cors-container will then proxy the specified resource and transform the original headers to be CORS permissive, whilst keeping origional headers in-tact.

If you intend to use this in production over the open web, ensure the service is locked down with restrictive firewall/access permissions, otherwise any content may be proxied over your server.

I suggest implementing proper CORS headers on your resources and using this for development purposes only.

Relative URL rewriting

cors-container can rewrite relative URLs to full URLs of the response body you have proxied.

For example if we wish to proxy http://blog.jacob.uk.com/ and cors-container is runinnng on http://localhost:3000/ the request URL would be http://localhost:3000/http://blog.jacob.uk.com/.

cors-container will rewrite any relative URLs it finds in the proxies response body. For example <a href="/css/style.css"> would be modified to <a href="http://localhost:3000/http://blog.jacob.uk.com/css/style.css"> in the proxied response.

This can be useful if you wish to be able to pull additional assets on a page through the proxy such as stylesheets and JavaScript.

This is enabled by default as this option mutates the original response body.

Set not-rewrite-urls in the request header to cors-cotainer if you don't want relative URLs rewriting.

Deploying

Docker(hub)
$ docker pull imjacobclark/cors-container
$ docker run --restart=always -d -p 3000:3000 --name cors-container imjacobclark/cors-container
Docker(source)
$ git pull https://github.com/imjacobclark/cors-container.git && cd cors-container
$ docker build -t cors-container
$ docker run --restart=always -d -p 3000:3000 --name cors-container cors-container
Node
$ git pull https://github.com/imjacobclark/cors-container.git && cd cors-container
$ npm run test && npm start

Thanks to

cors-container's People

Contributors

imjacobclark avatar asagajda avatar mrmx avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.