Skip to content

Commit

Permalink
feat: add INGRESS_TOKEN env variable to set the ingress session cookie (
Browse files Browse the repository at this point in the history
  • Loading branch information
darkbasic committed Sep 16, 2024
1 parent f9418aa commit 66c930c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
1 change: 1 addition & 0 deletions docs/development/intro.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,4 @@ that you can use to redirect to a different backend:
- **SERVER_SSL**: [Default: undefined] if set to a value it will use _https_/_wss_ to connect to the backend;
- **SERVER_URL**: [Default: use the other variables] the full URL for the backend API, IE: `https://zwavetomqtt.home.net:8443/`
- **SERVER_WS_URL**: [Default: use the other variables] the full URL for the backend Socket, IE: `wss://zwavetomqtt.home.net:8443/`
- **INGRESS_TOKEN**: [Default: undefined] a token to set the ingress session cookie if you want to develop against a remote backend via an Hass.io Ingress;
10 changes: 10 additions & 0 deletions vite.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ const proxyHostname = process.env.SERVER_HOST
? process.env.SERVER_HOST
: 'localhost'
const proxyPort = process.env.SERVER_PORT ? process.env.SERVER_PORT : '8091'
const ingressToken = process.env.INGRESS_TOKEN

const proxyURL = process.env.SERVER_URL
? process.env.SERVER_URL
Expand Down Expand Up @@ -112,16 +113,25 @@ export default defineConfig(({ mode }) => {
ws: true,
secure: false, // allow self signed certificates
changeOrigin: true,
...(ingressToken && {
headers: { cookie: `ingress_session=${ingressToken}` },
}),
},
'/health': {
target: proxyURL,
secure: false,
changeOrigin: true,
...(ingressToken && {
headers: { cookie: `ingress_session=${ingressToken}` },
}),
},
'/api': {
target: proxyURL,
secure: false,
changeOrigin: true,
...(ingressToken && {
headers: { cookie: `ingress_session=${ingressToken}` },
}),
},
},
},
Expand Down

0 comments on commit 66c930c

Please sign in to comment.