Skip to content

Commit a9b6ad2

Browse files
committed
Merge remote-tracking branch 'origin/4.5' into sw-backport-4.5.1
2 parents 94852df + 8b0691c commit a9b6ad2

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
# 4.5.1
2+
3+
### Bug Fixes
4+
5+
- [#43](https://github.com/okta/okta-oidc-middleware/pull/43) fix: correctly preprends `appBaseUrl` to redirect url when `appBaseUrl` contains a base path
6+
17
# 4.5.0
28

39
### Features

src/oidcUtil.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,11 @@ oidcUtil.ensureAuthenticated = (context, options = {}) => {
144144
if (req.session) {
145145
req.session.returnTo = req.originalUrl || req.url;
146146
}
147-
const url = options.redirectTo || (new URL(context.options.routes.login.path, context.options.appBaseUrl)).href;
147+
let url = options.redirectTo;
148+
if (!url) {
149+
const loginPath = context.options.routes.login.path;
150+
url = (new URL(loginPath[0] === '/' ? `.${loginPath}` : `/${loginPath}`, context.options.appBaseUrl + '/')).href;
151+
}
148152
return res.redirect(appendOptionsToQuery(url, options));
149153
}
150154

0 commit comments

Comments
 (0)