-
Notifications
You must be signed in to change notification settings - Fork 99
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: create different proxy setup for parrot
- Loading branch information
1 parent
f4646f6
commit b12125b
Showing
4 changed files
with
67 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# @inlang/telemetry-proxy-parrot | ||
|
||
The server that redirects telemetry requests to the correct server. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
{ | ||
"name": "@inlang/telemetry-proxy-parrot", | ||
"type": "module", | ||
"private": true, | ||
"scripts": { | ||
"dev": "node --loader tsx ./src/main.ts", | ||
"production": "NODE_ENV=production tsx ./src/main.ts", | ||
"lint": "eslint ./src --fix", | ||
"format": "prettier ./src --write", | ||
"clean": "rm -rf ./dist ./node_modules" | ||
}, | ||
"dependencies": { | ||
"express": "^4.18.2", | ||
"http-proxy-middleware": "^2.0.6", | ||
"tsx": "3.12.7" | ||
}, | ||
"devDependencies": { | ||
"@types/express": "^4.17.17", | ||
"typescript": "^5.5.2" | ||
}, | ||
"license": "Apache-2.0", | ||
"version": "0.0.1" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import express from "express" | ||
import { createProxyMiddleware } from "http-proxy-middleware" | ||
|
||
// --------------- SETUP ----------------- | ||
|
||
export const isProduction = process.env.NODE_ENV === "production" | ||
|
||
const app = express() | ||
|
||
// ----------------- ROUTES ---------------------- | ||
|
||
app.use( | ||
"*", | ||
createProxyMiddleware({ | ||
target: "https://eu.posthog.com", | ||
changeOrigin: true, | ||
onProxyReq: (req) => { | ||
req.path | ||
}, | ||
onProxyRes: (proxyRes) => { | ||
proxyRes.headers["Access-Control-Allow-Origin"] = "null" | ||
}, | ||
}) | ||
) | ||
|
||
// ----------------- START SERVER ----------------- | ||
|
||
const port = process.env.PORT ?? 4006 | ||
app.listen(port) | ||
console.info(`Server running at http://localhost:${port}/`) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{ | ||
"extends": "../tsconfig.base.json", | ||
"include": ["src/*.ts"], | ||
"compilerOptions": { | ||
// DOM because of fetch. TODO: extract fetch from this package and | ||
// let fetch be provided by the environment. | ||
"lib": ["ESNext", "DOM"], | ||
"types": [], | ||
"rootDir": "./src" | ||
} | ||
} |