Rework to use marbas and authentik instead of poketbase (#1)

Reviewed-on: #1
This commit was merged in pull request #1.
This commit is contained in:
2024-05-17 23:00:52 +02:00
parent 9fb78329cc
commit 717eaa6ed8
47 changed files with 2306 additions and 1049 deletions

View File

@@ -1,94 +1,25 @@
import vue from '@vitejs/plugin-vue';
import * as path from "path";
import { defineConfig, loadEnv } from 'vite';
import zlib from 'zlib';
import { defineConfig } from 'vite';
import runtimeEnv from 'vite-plugin-runtime-env';
export default defineConfig(({ mode }) => {
const env = loadEnv(mode, process.cwd(), '');
return {
plugins: [vue()],
resolve: {
alias: {
'src': path.resolve(__dirname, './src/'),
'@': path.resolve(__dirname, './src/'),
},
extensions: ['.mjs', '.js', '.ts', '.jsx', '.tsx', '.json', '.vue']
export default defineConfig({
plugins: [
runtimeEnv(),
vue(),
],
resolve: {
alias: {
'src': path.resolve(__dirname, './src/'),
'@': path.resolve(__dirname, './src/'),
},
server: {
port: 3000,
strictPort: true,
watch: {
usePolling: true
},
proxy: {
'/marbas/': {
target: env.MARBAS_URL,
changeOrigin: true,
followRedirects: true,
rewrite: path => path.replace(/^\/marbas/, ''),
selfHandleResponse: true,
configure: proxy => {
proxy.on('proxyRes', (proxyRes, req, res) => {
const chunks = [];
proxyRes.on("data", (chunk) => chunks.push(chunk));
proxyRes.on("end", () => {
const buffer = Buffer.concat(chunks);
const encoding = proxyRes.headers["content-encoding"];
const relace = (b: Buffer) => {
let remoteBody = b.toString();
const modifiedBody = remoteBody.replace(env.MARBAS_URL, '/marbas/');
res.write(modifiedBody);
res.end();
}
if (!encoding) {
relace(buffer);
} else if (encoding === "gzip" || encoding === "deflate") {
zlib.unzip(buffer, (err, b) => {
if (!err) {
relace(b);
} else {
console.error(err);
}
});
} else {
console.error(`Unsupported encoding: ${encoding}`);
}
});
});
}
},
'/pocketbase/': {
target: env.POCKET_BASE_URL,
changeOrigin: true,
followRedirects: true,
rewrite: path => path.replace(/^\/pocketbase/, ''),
},
'/evepraisal/': {
target: env.EVEPRAISAL_URL,
changeOrigin: true,
followRedirects: true,
rewrite: path => path.replace(/^\/evepraisal/, ''),
},
'/fuzzwork/': {
target: env.FUZZWORK_URL,
changeOrigin: true,
followRedirects: true,
rewrite: path => path.replace(/^\/fuzzwork/, ''),
},
'/esi/': {
target: env.ESI_URL,
changeOrigin: true,
followRedirects: true,
rewrite: path => path.replace(/^\/esi/, ''),
headers: {
'User-Agent': env.ESI_USER_AGENT
},
}
}
extensions: ['.mjs', '.js', '.ts', '.jsx', '.tsx', '.json', '.vue']
},
server: {
port: 3000,
strictPort: true,
watch: {
usePolling: true
}
};
})
}
});