Skip to content

Commit

Permalink
Make Vite dev proxy preserve the original Host header
Browse files Browse the repository at this point in the history
  • Loading branch information
daniel-lerch committed Feb 4, 2025
1 parent a2e5de0 commit 2677bed
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions webapp/vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,21 @@
import { fileURLToPath, URL } from "node:url"

import { defineConfig, loadEnv } from "vite"
import { defineConfig, loadEnv, ProxyOptions } from "vite"
import vue from "@vitejs/plugin-vue"

// https://vitejs.dev/config/
export default defineConfig(({ mode }) => {
const env = loadEnv(mode, process.cwd())

const proxy = {} as { [key: string]: string }
proxy[env.VITE_API_BASE_PATH + "api"] = env.VITE_API_ORIGIN
proxy[env.VITE_API_BASE_PATH + "signin-oidc"] = env.VITE_API_ORIGIN
proxy[env.VITE_API_BASE_PATH + "signout-callback-oidc"] = env.VITE_API_ORIGIN

const proxy = {} as Record<string, string | ProxyOptions>
const options = {
target: env.VITE_API_ORIGIN,
changeOrigin: false,
}
proxy[env.VITE_API_BASE_PATH + "api"] = options
proxy[env.VITE_API_BASE_PATH + "signin-oauth"] = options
proxy[env.VITE_API_BASE_PATH + "signin-oidc"] = options
proxy[env.VITE_API_BASE_PATH + "signout-callback-oidc"] = options
return {
plugins: [vue()],
resolve: {
Expand Down

0 comments on commit 2677bed

Please sign in to comment.