mirror of
https://github.com/movie-web/simple-proxy.git
synced 2025-09-13 14:43:26 +00:00
Compare commits
33 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
45aba5eb7f | ||
|
33bbe94692 | ||
|
97d65a47bb | ||
|
906b1bdf2f | ||
|
3fab3a39ec | ||
|
414b03cd8e | ||
|
f3612d4a4e | ||
|
f0d858460c | ||
|
9d2df30348 | ||
|
0af2174784 | ||
|
b25fc06857 | ||
|
84ac1c6fa1 | ||
|
2d4b1a5848 | ||
|
6097252cf0 | ||
|
3769b37e8a | ||
|
de07b4882b | ||
|
259b7bf1f7 | ||
|
2b77df66ec | ||
|
d907fa36f2 | ||
|
610ac5db2c | ||
|
ddabde15b6 | ||
|
e09decb8e2 | ||
|
440ae9bd2c | ||
|
d0c5a41c69 | ||
|
6bb6914798 | ||
|
f47e4f9ec1 | ||
|
b16ebe48b0 | ||
|
6828e31497 | ||
|
8b26bcf554 | ||
|
5a09e0c602 | ||
|
8852fca320 | ||
|
1e147a793d | ||
|
e88a4f3203 |
4
.github/workflows/cloudflare.yml
vendored
4
.github/workflows/cloudflare.yml
vendored
@@ -11,7 +11,7 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
timeout-minutes: 60
|
timeout-minutes: 60
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
- uses: pnpm/action-setup@v2
|
- uses: pnpm/action-setup@v2
|
||||||
with:
|
with:
|
||||||
@@ -20,7 +20,7 @@ jobs:
|
|||||||
- name: Install Node.js
|
- name: Install Node.js
|
||||||
uses: actions/setup-node@v3
|
uses: actions/setup-node@v3
|
||||||
with:
|
with:
|
||||||
node-version: 18
|
node-version: 20
|
||||||
cache: 'pnpm'
|
cache: 'pnpm'
|
||||||
|
|
||||||
- name: Install packages
|
- name: Install packages
|
||||||
|
@@ -14,16 +14,16 @@ jobs:
|
|||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout code
|
- name: Checkout code
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
- uses: pnpm/action-setup@v2
|
- uses: pnpm/action-setup@v2
|
||||||
with:
|
with:
|
||||||
version: latest
|
version: latest
|
||||||
|
|
||||||
- name: Install Node.js
|
- name: Install Node.js
|
||||||
uses: actions/setup-node@v3
|
uses: actions/setup-node@v4
|
||||||
with:
|
with:
|
||||||
node-version: 18
|
node-version: 20
|
||||||
cache: 'pnpm'
|
cache: 'pnpm'
|
||||||
|
|
||||||
- name: Install packages
|
- name: Install packages
|
||||||
@@ -41,16 +41,16 @@ jobs:
|
|||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout code
|
- name: Checkout code
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
- uses: pnpm/action-setup@v2
|
- uses: pnpm/action-setup@v2
|
||||||
with:
|
with:
|
||||||
version: latest
|
version: latest
|
||||||
|
|
||||||
- name: Install Node.js
|
- name: Install Node.js
|
||||||
uses: actions/setup-node@v3
|
uses: actions/setup-node@v4
|
||||||
with:
|
with:
|
||||||
node-version: 18
|
node-version: 20
|
||||||
cache: 'pnpm'
|
cache: 'pnpm'
|
||||||
|
|
||||||
- name: Install pnpm packages
|
- name: Install pnpm packages
|
||||||
@@ -58,3 +58,17 @@ jobs:
|
|||||||
|
|
||||||
- name: Build Project
|
- name: Build Project
|
||||||
run: pnpm build
|
run: pnpm build
|
||||||
|
|
||||||
|
docker:
|
||||||
|
name: Build docker
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Checkout code
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Set up Docker Buildx
|
||||||
|
uses: docker/setup-buildx-action@v3
|
||||||
|
|
||||||
|
- name: Build
|
||||||
|
uses: docker/build-push-action@v5
|
13
.github/workflows/publish.yml
vendored
13
.github/workflows/publish.yml
vendored
@@ -19,17 +19,17 @@ jobs:
|
|||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout repository
|
- name: Checkout repository
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
- name: Setup Docker buildx
|
- name: Setup Docker buildx
|
||||||
uses: docker/setup-buildx-action@v2
|
uses: docker/setup-buildx-action@v3
|
||||||
|
|
||||||
- name: Get version
|
- name: Get version
|
||||||
id: package-version
|
id: package-version
|
||||||
uses: martinbeentjes/npm-get-version-action@main
|
uses: martinbeentjes/npm-get-version-action@main
|
||||||
|
|
||||||
- name: Log into registry ${{ env.REGISTRY }}
|
- name: Log into registry ${{ env.REGISTRY }}
|
||||||
uses: docker/login-action@v2
|
uses: docker/login-action@v3
|
||||||
with:
|
with:
|
||||||
registry: ${{ env.REGISTRY }}
|
registry: ${{ env.REGISTRY }}
|
||||||
username: ${{ github.actor }}
|
username: ${{ github.actor }}
|
||||||
@@ -37,7 +37,7 @@ jobs:
|
|||||||
|
|
||||||
- name: Extract Docker metadata
|
- name: Extract Docker metadata
|
||||||
id: meta
|
id: meta
|
||||||
uses: docker/metadata-action@v4
|
uses: docker/metadata-action@v5
|
||||||
with:
|
with:
|
||||||
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
|
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
|
||||||
flavor: |
|
flavor: |
|
||||||
@@ -47,9 +47,12 @@ jobs:
|
|||||||
|
|
||||||
- name: Build and push Docker image
|
- name: Build and push Docker image
|
||||||
id: build-and-push
|
id: build-and-push
|
||||||
uses: docker/build-push-action@v4
|
uses: docker/build-push-action@v5
|
||||||
with:
|
with:
|
||||||
push: true
|
push: true
|
||||||
|
platforms: linux/amd64,linux/arm64
|
||||||
context: .
|
context: .
|
||||||
labels: ${{ steps.meta.outputs.labels }}
|
labels: ${{ steps.meta.outputs.labels }}
|
||||||
tags: ${{ steps.meta.outputs.tags }}
|
tags: ${{ steps.meta.outputs.tags }}
|
||||||
|
cache-from: type=gha
|
||||||
|
cache-to: type=gha,mode=max
|
||||||
|
4
.github/workflows/release.yml
vendored
4
.github/workflows/release.yml
vendored
@@ -12,7 +12,7 @@ jobs:
|
|||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout code
|
- name: Checkout code
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
- uses: pnpm/action-setup@v2
|
- uses: pnpm/action-setup@v2
|
||||||
with:
|
with:
|
||||||
@@ -41,7 +41,7 @@ jobs:
|
|||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
with:
|
with:
|
||||||
tag_name: v${{ steps.package-version.outputs.current-version }}
|
tag_name: v${{ steps.package-version.outputs.current-version }}
|
||||||
release_name: Bot v${{ steps.package-version.outputs.current-version }}
|
release_name: Simple-proxy v${{ steps.package-version.outputs.current-version }}
|
||||||
draft: false
|
draft: false
|
||||||
prerelease: false
|
prerelease: false
|
||||||
body: |
|
body: |
|
||||||
|
1
.gitignore
vendored
1
.gitignore
vendored
@@ -5,3 +5,4 @@ node_modules
|
|||||||
.output
|
.output
|
||||||
.env
|
.env
|
||||||
dist
|
dist
|
||||||
|
.netlify
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
FROM node:18-alpine as base
|
FROM node:20-alpine as base
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
# Build layer
|
# Build layer
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
# simple-proxy
|
# simple-proxy
|
||||||
|
|
||||||
Simple reverse proxy to bypass CORS, used by [movie-web](https://movie-web.app).
|
Simple reverse proxy to bypass CORS, used by [movie-web](https://movie-web.app).
|
||||||
Read the docs at https://docs.movie-web.app/proxy
|
Read the docs at https://docs.movie-web.app/proxy/introduction
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
@@ -18,3 +18,4 @@ Read the docs at https://docs.movie-web.app/proxy
|
|||||||
- cloudflare workers
|
- cloudflare workers
|
||||||
- AWS lambda
|
- AWS lambda
|
||||||
- nodejs
|
- nodejs
|
||||||
|
- netlify edge functions
|
||||||
|
4
netlify.toml
Normal file
4
netlify.toml
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
[build]
|
||||||
|
command = "pnpm build:netlify"
|
||||||
|
publish = "."
|
||||||
|
edge_functions = ".netlify"
|
15
package.json
15
package.json
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "simple-proxy",
|
"name": "simple-proxy",
|
||||||
"private": true,
|
"private": true,
|
||||||
"version": "2.1.2",
|
"version": "2.1.4",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"prepare": "nitropack prepare",
|
"prepare": "nitropack prepare",
|
||||||
"dev": "nitropack dev",
|
"dev": "nitropack dev",
|
||||||
@@ -9,15 +9,16 @@
|
|||||||
"build:cloudflare": "NITRO_PRESET=cloudflare npm run build",
|
"build:cloudflare": "NITRO_PRESET=cloudflare npm run build",
|
||||||
"build:aws": "NITRO_PRESET=aws_lambda npm run build",
|
"build:aws": "NITRO_PRESET=aws_lambda npm run build",
|
||||||
"build:node": "NITRO_PRESET=node-server npm run build",
|
"build:node": "NITRO_PRESET=node-server npm run build",
|
||||||
|
"build:netlify": "NITRO_PRESET=netlify_edge npm run build",
|
||||||
"start": "node .output/server/index.mjs",
|
"start": "node .output/server/index.mjs",
|
||||||
"lint": "eslint --ext .ts src/",
|
"lint": "eslint --ext .ts src/",
|
||||||
"lint:fix": "eslint --fix --ext .ts src/",
|
"lint:fix": "eslint --fix --ext .ts src/",
|
||||||
"preinstall": "npx only-allow pnpm"
|
"preinstall": "npx only-allow pnpm"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"h3": "^1.9.0",
|
"h3": "^1.10.0",
|
||||||
"jose": "^5.2.0",
|
"jose": "^5.2.0",
|
||||||
"nitropack": "latest"
|
"nitropack": "^2.8.1"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@typescript-eslint/eslint-plugin": "^6.7.0",
|
"@typescript-eslint/eslint-plugin": "^6.7.0",
|
||||||
@@ -26,6 +27,12 @@
|
|||||||
"eslint-config-airbnb-base": "^15.0.0",
|
"eslint-config-airbnb-base": "^15.0.0",
|
||||||
"eslint-config-prettier": "^9.0.0",
|
"eslint-config-prettier": "^9.0.0",
|
||||||
"eslint-import-resolver-typescript": "^3.6.0",
|
"eslint-import-resolver-typescript": "^3.6.0",
|
||||||
"eslint-plugin-prettier": "^5.0.0"
|
"eslint-plugin-prettier": "^5.0.0",
|
||||||
|
"@rollup/wasm-node": "^4.9.4"
|
||||||
|
},
|
||||||
|
"pnpm": {
|
||||||
|
"overrides": {
|
||||||
|
"rollup": "npm:@rollup/wasm-node"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
709
pnpm-lock.yaml
generated
709
pnpm-lock.yaml
generated
File diff suppressed because it is too large
Load Diff
@@ -41,17 +41,22 @@ export default defineEventHandler(async (event) => {
|
|||||||
const token = await createTokenIfNeeded(event);
|
const token = await createTokenIfNeeded(event);
|
||||||
|
|
||||||
// proxy
|
// proxy
|
||||||
await specificProxyRequest(event, destination, {
|
try {
|
||||||
blacklistedHeaders: getBlacklistedHeaders(),
|
await specificProxyRequest(event, destination, {
|
||||||
fetchOptions: {
|
blacklistedHeaders: getBlacklistedHeaders(),
|
||||||
redirect: 'follow',
|
fetchOptions: {
|
||||||
headers: getProxyHeaders(event.headers),
|
redirect: 'follow',
|
||||||
body,
|
headers: getProxyHeaders(event.headers),
|
||||||
},
|
body,
|
||||||
onResponse(outputEvent, response) {
|
},
|
||||||
const headers = getAfterResponseHeaders(response.headers, response.url);
|
onResponse(outputEvent, response) {
|
||||||
setResponseHeaders(outputEvent, headers);
|
const headers = getAfterResponseHeaders(response.headers, response.url);
|
||||||
if (token) setTokenHeader(event, token);
|
setResponseHeaders(outputEvent, headers);
|
||||||
},
|
if (token) setTokenHeader(event, token);
|
||||||
});
|
},
|
||||||
|
});
|
||||||
|
} catch (e) {
|
||||||
|
console.log('Error fetching', e);
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
@@ -20,6 +20,7 @@ const blacklistedHeaders = [
|
|||||||
'x-forwarded-proto',
|
'x-forwarded-proto',
|
||||||
'forwarded',
|
'forwarded',
|
||||||
'x-real-ip',
|
'x-real-ip',
|
||||||
|
'content-length',
|
||||||
...Object.keys(headerMap),
|
...Object.keys(headerMap),
|
||||||
];
|
];
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user