Skip to content
This repository was archived by the owner on Apr 8, 2020. It is now read-only.
This repository was archived by the owner on Apr 8, 2020. It is now read-only.

SSR with authentication (React + Redux) #727

Closed

Description

@Kevenvz

Hey all,

I'm working on my first react + redux application and got everything working so far with windows authentication. I passed the 'same-origin' value to the credentials parameter in fetch() and it's working as intended.

The only problem is that SSR isn't working on a page that has to initially make some api calls, I can't really figure out a solution so that's why I'm asking for help.

I'm using the default React + Redux template with IIS Express windows authentication enabled.

Thanks in advance!

Activity

  1. SteveSandersonMS commented on Mar 7, 2017

    @SteveSandersonMS
    Member

    When you're doing server-side prerendering, you can pass arbitrary (JSON-serializable) data from .NET into your boot-server.ts code. To do this, see Passing data from .NET code into JavaScript code on this page of docs: https://github.com/aspnet/JavaScriptServices/blob/dev/src/Microsoft.AspNetCore.SpaServices/README.md

    Using this technique, you can pass whatever authentication credentials or token you have in .NET code to boot-server.ts, and use that whenever you call fetch. For example, you could take an auth token from some incoming HTTP header in .NET code, and send the same HTTP header when you make fetch calls.

    I know this is not trivial to implement. The reason there's no built-in feature for replaying auth tokens like that is that it would be a huge security issue if your app was calling third-party APIs (unless you take steps to control exactly which fetch calls get the auth context, you might be leaking credentials to third parties).

  2. jeinz11 commented on May 30, 2017

    @jeinz11

    hi @SteveSandersonMS i passed my cookies in the globals but i cant retrieve it inside my reducer
    so no way plugging it in our fetch request

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions