File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 22# Core Application Settings
33# ###########################
44
5+ # Public URL where WoL Redirect is accessible
6+ # Used for absolute redirects, links, and OAuth flows
7+ # Example: https://wol-red.mydomain.com
8+ APP_URL =
9+
10+ # Base path the application is served from
11+ # Leave empty or "/" if served from the root
12+ # Example: /wol or /apps/wol
13+ BASE_PATH = /
14+
515# Path to the service mapping configuration file
616CONFIG_PATH = /app/config/mapping.json
717
Original file line number Diff line number Diff line change 1- import express from "express"
1+ import express , { Router } from "express"
22import { createServer } from "http"
33import cookieParser from "cookie-parser"
44
@@ -43,8 +43,12 @@ await Init()
4343
4444app . use ( cookieParser ( ) )
4545
46- app . use ( "/" , auth ( ) )
47- app . use ( "/" , wol ( ) )
46+ const rootRouter = Router ( )
47+
48+ rootRouter . use ( "/" , auth ( ) )
49+ rootRouter . use ( "/" , wol ( ) )
50+
51+ app . use ( env . ENV . basePath , rootRouter )
4852
4953app . use ( ( err , req , res , next ) => {
5054 log . logger . error ( err )
Original file line number Diff line number Diff line change @@ -248,17 +248,25 @@ function registerFakeAuth() {
248248}
249249
250250export function Router ( ) {
251- try {
252- redirectURL = new URL ( ENV . redirectURL )
253- } catch { }
254-
255251 if ( ENV . useOauth ) {
252+ if ( ENV . redirectURL ) {
253+ try {
254+ redirectURL = new URL ( ENV . redirectURL )
255+ } catch { }
256+ }
257+
256258 if ( ! redirectURL ) {
257259 logger . error ( "Error parsing redirect URL: " , ENV . redirectURL )
258260 }
259261
260262 registerOauth ( )
261263 } else {
264+ if ( ENV . appURL ) {
265+ try {
266+ redirectURL = new URL ( ENV . appURL )
267+ } catch { }
268+ }
269+
262270 registerFakeAuth ( )
263271 }
264272
Original file line number Diff line number Diff line change @@ -7,6 +7,9 @@ export const ENV = {
77 port : "6789" ,
88 logLevel : "info" ,
99
10+ appURL : "" ,
11+ basePath : "" ,
12+
1013 exposeLogs : true ,
1114 useOauth : true ,
1215
@@ -46,6 +49,21 @@ export function Load() {
4649 ENV . port = process . env . PORT || ENV . port
4750 ENV . logLevel = process . env . LOG_LEVEL || ENV . logLevel
4851
52+ const appUrl = process . env . APP_URL || ""
53+
54+ let basePath = process . env . BASE_PATH || ""
55+
56+ if ( appUrl && ! basePath ) {
57+ try {
58+ const appURL = new URL ( appUrl )
59+ basePath = appURL . pathname
60+ } catch { }
61+ }
62+
63+ if ( basePath ) {
64+ ENV . basePath = ENV . appURL . pathname . replace ( / \/ $ / , "" )
65+ }
66+
4967 ENV . redisHost = process . env . REDIS_HOST || ENV . redisHost
5068 ENV . redisPort = process . env . REDIS_PORT || ENV . redisPort
5169 ENV . redisUser = process . env . REDIS_USER || ENV . redisUser
Original file line number Diff line number Diff line change 155155 }, 250 )
156156 }
157157 },
158+ endpoint: ` ${ window .location .origin } /start` ,
158159 })
159160 }
160161
You can’t perform that action at this time.
0 commit comments