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

Commit da557b4

Browse files
authored
Merge pull request #282 from Azure-Samples/fix-issue-with-port
Fix issue with port is undefined in hybrid SPA sample
2 parents 34ff20e + be93ea6 commit da557b4

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
@@ -1,5 +1,6 @@
11
require("dotenv").config();
22
const msalInstance = require("../msal");
3+
const port = process.env.PORT || 5000;
34

45
exports.loginUser = async (req, res, next) => {
56
const authCodeUrlParameters = {
@@ -30,7 +31,7 @@ exports.handleRedirectWithCode = (req, res, next) => {
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)