How can I share a local storage token in one domain, but with another host?

Project 1: MVC application:

So, I have a regular .Net Core MVC application that the user will land when they switch to myDomain.com, which is located on port 3000. Here I use ordinary controllers and razor views, etc. In this application, the user can login, at which point the JWT token will be returned and stored in local storage. They will also be moved to the user portal (hosted on port 3001). This MVC application will also contain API controllers for my user portal.

Project 2: SPA application (user portal):

A user portal is basically a separate SPA client project using a reaction that will be hosted on port 3001, which has its own separate node js server and makes MVC project API calls on port 3000.

So my problem is, how can I save the entry token in these two ports? Is it possible? Does this architecture make sense? Any evidence you can provide on this subject will be greatly appreciated.

+4
source share
2 answers

Put a simple reverse proxy in front of the web servers. Then you can serve two pages in one domain:

myDomain.com/application1 --> reverse proxy to port 3000
myDomain.com/application2 --> reverse proxy to port 3001

or

app1.myDomain.com --> port 3000
app2.myDomain.com --> port 3001

You can configure reverse proxy in IIS or just use nginx.

+2

Source: https://habr.com/ru/post/1677075/


All Articles