Skip to content

Commit

Permalink
chore: rework dev proxy setup for better performance (no more 503!)
Browse files Browse the repository at this point in the history
  • Loading branch information
MiniDigger committed Aug 3, 2024
1 parent ad6effd commit 432ed06
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 71 deletions.
2 changes: 1 addition & 1 deletion chart/dockerfiles/backend/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@ ENV TERM xterm-256color

EXPOSE 8080
# "-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005" is for debug only
ENTRYPOINT ["java", "-XX:+CrashOnOutOfMemoryError", "--enable-preview", "-jar", "app.jar"]
ENTRYPOINT ["java", "-XX:+CrashOnOutOfMemoryError", "-jar", "app.jar"]

ADD --chown=java:java backend/target/hangar-*.jar /hangar/app.jar
6 changes: 0 additions & 6 deletions chart/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,6 @@ ingress:
- path: /global-sitemap.xml
pathType: ImplementationSpecific
target: backend
- path: /graphiql
pathType: ImplementationSpecific
target: backend
- path: /graphql
pathType: ImplementationSpecific
target: backend
- path: /.well-known
pathType: ImplementationSpecific
target: backend
Expand Down
46 changes: 14 additions & 32 deletions frontend/nuxt.config.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import IconsResolver from "unplugin-icons/resolver";
// import EslintPlugin from "vite-plugin-eslint";
import Components from "unplugin-vue-components/vite";
import type { ProxyOptions } from "@nuxt-alt/proxy";
import { defineNuxtConfig } from "nuxt/config";
import { loadLocales } from "./src/i18n/i18n-util";

Expand Down Expand Up @@ -51,7 +50,6 @@ export default defineNuxtConfig({
modules: [
"@unocss/nuxt",
"@pinia/nuxt",
"@nuxt-alt/proxy",
"unplugin-icons/nuxt",
"@vueuse/nuxt",
"@nuxtjs/i18n",
Expand Down Expand Up @@ -149,41 +147,25 @@ export default defineNuxtConfig({
isCustomElement: (tag) => ["lottie-player", "rapi-doc"].includes(tag),
},
},
proxy: {
proxies: {
// for performance, these should be mirrored in ingress
"/api/": defineProxyBackend(),
"/signup": defineProxyBackend(),
"/login": defineProxyBackend(),
"/logout": defineProxyBackend(),
"/handle-logout": defineProxyBackend(),
"/refresh": defineProxyBackend(),
"/invalidate": defineProxyBackend(),
"/v3/api-docs": defineProxyBackend(),
"/robots.txt": defineProxyBackend(),
"/sitemap.xml": defineProxyBackend(),
"/global-sitemap.xml": defineProxyBackend(),
"^/.*/sitemap.xml": defineProxyBackend(),
"/statusz": defineProxyBackend(),
},
},
// cache statics for a year
routeRules: {
"/_nuxt/**": { headers: { "Cache-Control": "max-age=31536000, immutable" } },
"/**/*.js": { headers: { "Cache-Control": "max-age=31536000, immutable" } },
"/**/*.mjs": { headers: { "Cache-Control": "max-age=31536000, immutable" } },
"/**/*.css": { headers: { "Cache-Control": "max-age=31536000, immutable" } },
"/**/*.json": { headers: { "Cache-Control": "max-age=31536000, immutable" } },
"/**/*.xml": { headers: { "Cache-Control": "max-age=31536000, immutable" } },
"/**/*.svg": { headers: { "Cache-Control": "max-age=31536000, immutable" } },
"/_nuxt/**": cache(),
"/**/*.js": cache(),
"/**/*.mjs": cache(),
"/**/*.css": cache(),
"/**/*.json": cache(),
"/**/*.xml": cache(),
"/**/*.svg": cache(),
"/api/**": proxy(),
},
});

function defineProxyBackend(): ProxyOptions {
function cache() {
return { headers: { "Cache-Control": "max-age=31536000, immutable" } };
}

function proxy() {
return {
configure: (proxy, options) => {
options.target = process.env.BACKEND_HOST || process.env.NITRO_BACKEND_HOST || "http://localhost:8080";
},
changeOrigin: true,
proxy: (process.env.BACKEND_HOST || process.env.NITRO_BACKEND_HOST || "http://localhost:8080") + "/api/**",
};
}
1 change: 0 additions & 1 deletion frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@
},
"devDependencies": {
"@iconify-json/mdi": "1.1.67",
"@nuxt-alt/proxy": "2.5.8",
"@nuxtjs/eslint-config-typescript": "12.1.0",
"@nuxtjs/i18n": "8.3.3",
"@sentry/bun": "8.22.0",
Expand Down
31 changes: 0 additions & 31 deletions frontend/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 432ed06

Please sign in to comment.