From 808d8467377618d401aa3ab71c3faf862c748170 Mon Sep 17 00:00:00 2001 From: Niccolo Borgioli Date: Fri, 17 Jan 2025 18:11:03 +0100 Subject: [PATCH] remove proxy --- packages/frontend/vite.config.js | 9 +++++++-- packages/proxy/package.json | 12 ------------ packages/proxy/proxy.js | 16 ---------------- 3 files changed, 7 insertions(+), 30 deletions(-) delete mode 100644 packages/proxy/package.json delete mode 100644 packages/proxy/proxy.js diff --git a/packages/frontend/vite.config.js b/packages/frontend/vite.config.js index 2c7d320..265832f 100644 --- a/packages/frontend/vite.config.js +++ b/packages/frontend/vite.config.js @@ -1,12 +1,17 @@ import { sveltekit } from '@sveltejs/kit/vite' import precompileIntl from 'svelte-intl-precompile/sveltekit-plugin' -const port = 8001 +const port = 3000 /** @type {import('vite').UserConfig} */ const config = { clearScreen: false, - server: { port }, + server: { + port, + proxy: { + '/api': 'http://localhost:8000', + }, + }, preview: { port }, plugins: [sveltekit(), precompileIntl('locales')], } diff --git a/packages/proxy/package.json b/packages/proxy/package.json deleted file mode 100644 index 24a2156..0000000 --- a/packages/proxy/package.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "private": true, - "name": "@cryptgeon/proxy", - "type": "module", - "main": "./proxy.js", - "scripts": { - "dev": "node ." - }, - "dependencies": { - "http-proxy": "^1.18.1" - } -} diff --git a/packages/proxy/proxy.js b/packages/proxy/proxy.js deleted file mode 100644 index f434436..0000000 --- a/packages/proxy/proxy.js +++ /dev/null @@ -1,16 +0,0 @@ -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, proxyTimeout: 250, timeout: 250 }) -}) -server.listen(3000) -console.log('Proxy on http://localhost:3000')