Giter Site home page Giter Site logo

cors-proxy's Introduction

CORS proxy

Simple AWS Lambda based proxy server for making CORS requests from browser to any HTTP server.

Run locally

1. Install

npm install

2. Run

node_modules/.bin/serverless offline

or

npm run offline

3. Use

Open your browser and go to http://localhost:3000/?url=<origin page>. For example:

http://localhost:3000/?url=https://github.com/

Run on AWS

0. Requirements

You need AWS account first. Also you need your IAM user has access to deploy AWS lambdas.

node_modules/.bin/serverless config credentials --provider aws --key <aws_key> --secret <aws_secret>

1. Install

npm install

2. Deploy

node_modules/.bin/serverless deploy --region <aws_region>

or

npm run deploy

You will see such console response:

Serverless: Packaging service...
Serverless: Excluding development dependencies...
Serverless: Creating Stack...
Serverless: Checking Stack create progress...
.....
Serverless: Stack create finished...
Serverless: Uploading CloudFormation file to S3...
Serverless: Uploading artifacts...
Serverless: Uploading service .zip file to S3 (16.08 MB)...
Serverless: Validating template...
Serverless: Updating Stack...
Serverless: Checking Stack update progress...
..............................
Serverless: Stack update finished...
Service Information
service: cors-proxy
stage: dev
region: eu-central-1
stack: cors-proxy-dev
api keys:
  None
endpoints:
  GET - https://qwertyuiop.execute-api.eu-central-1.amazonaws.com/dev/
functions:
  lambda: cors-proxy-dev-lambda

3. Use

Open your browser and use endpoint field from previous console response as base address. For example:

https://qwertyuiop.execute-api.eu-central-1.amazonaws.com/dev/?url=https://github.com/

cors-proxy's People

Contributors

antoniopresto avatar glifery avatar jaredkotoff avatar koxon avatar theseraya avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

cors-proxy's Issues

passing accept-encoding causes problems

I just set this up and hit a weird case while testing. Firefox sends an "accept-encoding: gzip" header. The default behavior of the code to to pass this header on, but it doesn't include an encoding header with the returned data, so I was seeing results that were compressed but being interpreted badly by the receiver.

I locally solved it by just deleting any "accept-encoding" headers before sending the request, but it would probably be better to pass on the returned content-encoding header if provided.

Confusing lambda function name

While the function appears with the name cors-proxy, if you want to see AWS logs, you need to use sls logs -s dev -f lambda -t.
According to the doc, the name serverless uses is the direct child of the functions property, thus in this case lambda.
While this might be an error/bug in Serverless itself, would be nice to see how to query the aws logs in readme.md

The original error I got was:

$ node_modules/.bin/serverless logs -s dev -f cors-proxy -t
 
  Serverless Error ---------------------------------------
 
  Function "cors-proxy" doesn't exist in this Service

error: "Serverless-offline: route not found."

Many thanks for creating and maintaining this project :)

I just cloned it locally and followed the install instructions to run locally. I put http://localhost:3000/?url=https://github.com/ into the browser but got the error message below:

{ currentRoute: "get - /", error: "Serverless-offline: route not found.", existingRoutes: [ "put - /dev", "post - /dev", "get - /dev" ], statusCode: 404 }

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.