server-side prerendering and redirectUrl from window.location.origin #938

Closed
opened 2025-08-09 17:18:15 +00:00 by fergalmoran · 0 comments
Owner

Originally created by @ghost on 3/14/2017

Hi, I need a complete callback URL for OAuth server-side. I'm setting up authentication in routes.tsx and the following window.location.origin gives me the error below. I have seen here (https://github.com/aspnet/JavaScriptServices/tree/dev/src/Microsoft.AspNetCore.SpaServices#server-side-prerendering) that one can pass in params from the MVC View ... but seems a bit convoluted. What is the solution to this?

    // Configure OAuth
    this.logingui = new OAuthLogin(clientId, domain, {
        auth: {
            redirectUrl: `**${window.location.origin}**/login`,
            responseType: 'token'
        }
    }) 

Error:
fail: Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddleware[0]
An unhandled exception has occurred: Call to Node module failed with error: Prerendering failed because of error: ReferenceError: window is not defined
at new AuthService (C:_d\cl\ClientApp\dist\main-server.js:24373:30)

*Originally created by @ghost on 3/14/2017* Hi, I need a complete callback URL for OAuth server-side. I'm setting up authentication in routes.tsx and the following window.location.origin gives me the error below. I have seen here (https://github.com/aspnet/JavaScriptServices/tree/dev/src/Microsoft.AspNetCore.SpaServices#server-side-prerendering) that one can pass in params from the MVC View ... but seems a bit convoluted. What is the solution to this? // Configure OAuth this.logingui = new OAuthLogin(clientId, domain, { auth: { redirectUrl: `**${window.location.origin}**/login`, responseType: 'token' } }) Error: fail: Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddleware[0] An unhandled exception has occurred: Call to Node module failed with error: Prerendering failed because of error: ReferenceError: window is not defined at new AuthService (C:\_d\cl\ClientApp\dist\main-server.js:24373:30)
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github/JavaScriptServices#938
No description provided.