Skip to content
This repository was archived by the owner on May 3, 2024. It is now read-only.

Commit 48b3b9f

Browse files
committed
fix issue with port in hybrid SPA sample
1 parent 34ff20e commit 48b3b9f

File tree

1 file changed

+3
-8
lines changed

1 file changed

+3
-8
lines changed

6-AdvancedScenarios/4-sign-in-hybrid/App/controllers/authController.js

+3-8
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,14 @@ exports.loginUser = async (req, res, next) => {
2424
* to be redeemed by your single-page application.
2525
*/
2626
exports.handleRedirectWithCode = (req, res, next) => {
27+
const port = process.env.PORT || 5000;
2728
const tokenRequest = {
2829
code: req.body.code,
2930
redirectUri: process.env.REDIRECT_URI,
3031
enableSpaAuthorizationCode: true,
3132
scopes: ["User.Read"],
3233
};
33-
34+
3435
msalInstance
3536
.acquireTokenByCode(tokenRequest)
3637
.then((response) => {
@@ -48,13 +49,7 @@ exports.handleRedirectWithCode = (req, res, next) => {
4849
req.session.referredUsername = preferredUsername;
4950
req.session.authenticated = true;
5051

51-
const urlFrom = (urlObject) =>
52-
String(
53-
Object.assign(
54-
new URL(`http://localhost:${process.env.port ? port : 5000}`),
55-
urlObject
56-
)
57-
);
52+
const urlFrom = (urlObject) => String(Object.assign(new URL(`http://localhost:${port}`), urlObject));
5853

5954
res.redirect(
6055
urlFrom({

0 commit comments

Comments
 (0)