sls-http-proxy
TypeScript icon, indicating that this package has built-in type declarations

0.0.1 • Public • Published

sls-http-proxy

Serverless Http Proxy on Cloudflare Worker, Deno Deploy or more ...

Get Start

Deploy to Serverless platform

Choose your favorite platform to deploy some code, check the simple code on below.

Cloudflare Worker

import { createSlsHttpProxy } from 'sls-http-proxy'

// get tokens from env `TOKENS` and split with `,`
const tokens = TOKENS.split(',')

const proxy = createSlsHttpProxy({ tokens })

addEventListener('fetch', event => {
  event.respondWith(proxy(event.request))
})

Deno Deploy

import { serve } from 'https://deno.land/std@0.114.0/http/server.ts'
import { createSlsHttpProxy } from 'https://x.nest.land/sls_http_proxy@0.0.1/mod.ts'

// get tokens from env `TOKENS` and split with `,`
const tokens = (Deno.env.get('TOKENS') ?? '').split(',')

const proxy = createSlsHttpProxy({ tokens })

await serve(proxy)

Send Request through proxy

for example: fetch send request to https://api.example.com/v1/products

const response = await fetch('https://your-proxy-host/v1/products', {
  headers: new Headers({
    'Px-Host': 'api.example.com',
    'Px-Token': 'your-proxy-token',
  })
})

Readme

Keywords

none

Package Sidebar

Install

npm i sls-http-proxy

Weekly Downloads

1

Version

0.0.1

License

none

Unpacked Size

13.4 kB

Total Files

7

Last publish

Collaborators

  • aa900031