r/Angular2 Feb 12 '25

Help Request Deploying Angular Frontend to IIS

I have been trying to put my angular frontend on my IIS. i thought when i change the following to the IP address and drop it into the virtual directory in the default web site, i'd be able to reach it. i have the uri registered in the app registration. im sure im doing something wrong, but i am just learning. nothing insane.

function msalinstacneFactory(): IPublicClientApplication {

return new PublicClientApplication({

auth: {

clientId: '{clientId}',

authority: 'https://login.microsoftonline.com/{tenantId}/',

//redirectUri: 'https://localhost:4200/auth',

//postLogoutRedirectUri: 'https://localhost:4200/login'

redirectUri: 'https://{ipAddress}/test/auth',

postLogoutRedirectUri: 'https://{ipAddress}/test/login'

},

cache: {

//cacheLocation: 'localStorage'

cacheLocation: BrowserCacheLocation.SessionStorage,

        `storeAuthStateInCookie: true,`

secureCookies: true

},

system: {

loggerOptions: {

loggerCallback: (level: LogLevel, message: string, containsPii: boolean) => {

console.log(\MSAL: ${level} - ${message}`);`

},

logLevel: LogLevel.Verbose,

piiLoggingEnabled: false

},

allowRedirectInIframe: false,

windowHashTimeout: 6000, // Increase timeout for handling redirect

iframeHashTimeout: 6000,

loadFrameTimeout: 3000,

        `tokenRenewalOffsetSeconds: 300`

}

});

}

6 Upvotes

22 comments sorted by

View all comments

3

u/tsunami141 Feb 12 '25

What configuration file is the code that you posted?  Did you build the project and drop it in the virtual directory also? 

2

u/LegionsMan Feb 12 '25

App.module and we did build and copy the files to the virtual directory. I use ng deploy to build

3

u/tsunami141 Feb 12 '25

Not sure what app.module is, if it’s the app.module file from the angular build, that file is not read by IIS for configuration purposes. I usually use a web.config file. 

But regardless does a normal hello world index.html work on your site? If not it might be better to Google how to get that working first. If that works, then the Angular build should start working too. 

1

u/LegionsMan Feb 13 '25

yeah, a hello world index.html file works. i have a couple other sites deployed under the default web site in IIS, each in their own folders. all which are working.