forked from fabianluque/ha-fusion
-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.js
31 lines (26 loc) · 762 Bytes
/
server.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import { handler } from './build/handler.js';
import express from 'express';
import { createProxyMiddleware } from 'http-proxy-middleware';
import dotenv from 'dotenv';
// dotenv is only used for local build
// it's not used when building container
dotenv.config();
const app = express();
const PORT = process.env.PORT || 5050;
// production proxy
if (process.env.HASS_URL) {
app.use(
['/local/', '/api/*_proxy*'],
createProxyMiddleware({
target: process.env.HASS_URL,
changeOrigin: true
})
);
}
// let sveltekit handle everything else
app.use(handler);
app.listen(PORT, () => {
console.debug(`listening on port ${PORT}`);
console.debug(`env HASS_URL ${process.env.HASS_URL}`);
console.debug(`env ADDON ${process.env.ADDON || false}`);
});