@@ -4,7 +4,7 @@ import { WebsocketRequest } from "../../../typings/pluginapi"
4
4
import { logError } from "../../common/util"
5
5
import { toVsCodeArgs } from "../cli"
6
6
import { isDevMode } from "../constants"
7
- import { ensureAuthenticated , authenticated , redirect } from "../http"
7
+ import { authenticated , ensureAuthenticated , redirect , self } from "../http"
8
8
import { loadAMDModule , readCompilationStats } from "../util"
9
9
import { Router as WsRouter } from "../wsRouter"
10
10
import { errorHandler } from "./errors"
@@ -25,9 +25,9 @@ export class CodeServerRouteWrapper {
25
25
const isAuthenticated = await authenticated ( req )
26
26
27
27
if ( ! isAuthenticated ) {
28
+ const to = self ( req )
28
29
return redirect ( req , res , "login" , {
29
- // req.baseUrl can be blank if already at the root.
30
- to : req . baseUrl && req . baseUrl !== "/" ? req . baseUrl : undefined ,
30
+ to : to !== "/" ? to : undefined ,
31
31
} )
32
32
}
33
33
@@ -46,9 +46,8 @@ export class CodeServerRouteWrapper {
46
46
( query . folder || query . workspace ) &&
47
47
! req . args [ "ignore-last-opened" ] // This flag disables this behavior.
48
48
) {
49
- // Redirect to the same page but with the query parameters attached
50
- // (preserving the trailing slash if any).
51
- return redirect ( req , res , req . baseUrl + ( req . originalUrl . endsWith ( "/" ) ? "/" : "" ) , {
49
+ const to = self ( req )
50
+ return redirect ( req , res , to , {
52
51
folder : query . folder ,
53
52
workspace : query . workspace ,
54
53
} )
0 commit comments