mirror of
https://github.com/cupcakearmy/cryptgeon.git
synced 2025-09-05 17:00:39 +00:00
CLI (#84)
* move to packages * update deps * update deps * actions maintenance * don't use blob * cli * fix default import * use synthetic default imports * remove comment * cli packaging * node 18 guard * packages * build system * testing * test pipeline * pipelines * changelog * version bump * update locales * update deps * update deps * update dependecies
This commit is contained in:
12
packages/proxy/package.json
Normal file
12
packages/proxy/package.json
Normal file
@@ -0,0 +1,12 @@
|
||||
{
|
||||
"private": true,
|
||||
"name": "@cryptgeon/proxy",
|
||||
"type": "module",
|
||||
"main": "./proxy.js",
|
||||
"scripts": {
|
||||
"dev": "node ."
|
||||
},
|
||||
"dependencies": {
|
||||
"http-proxy": "^1.18.1"
|
||||
}
|
||||
}
|
16
packages/proxy/proxy.js
Normal file
16
packages/proxy/proxy.js
Normal file
@@ -0,0 +1,16 @@
|
||||
import http from 'http'
|
||||
import httpProxy from 'http-proxy'
|
||||
|
||||
const proxy = httpProxy.createProxyServer()
|
||||
proxy.on('error', function (err, req, res) {
|
||||
console.error(err)
|
||||
res.writeHead(500, { 'Content-Type': 'text/plain' })
|
||||
res.end('500 Internal Server Error')
|
||||
})
|
||||
|
||||
const server = http.createServer(function (req, res) {
|
||||
const target = req.url.startsWith('/api/') ? 'http://127.0.0.1:8000' : 'http://localhost:8001'
|
||||
proxy.web(req, res, { target })
|
||||
})
|
||||
server.listen(1234)
|
||||
console.log('Proxy on http://localhost:1234')
|
Reference in New Issue
Block a user