Now that the front and back ends are separated, the stateless model should be accepted. Try other ways to solve the state saving problem.
For example: User information can be returned in the login interface and processed by the front end.
Use nginx as a reverse proxy and map services on different ports to a unified port to achieve cookie sharing
nginx configuration file example:
server { listen 8080; server_name example.com; # 将/api路径映射到3000端口 location ~ ^/(api)/ { proxy_pass http://127.0.0.1:3000; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; proxy_set_header Host $host; } # 静态资源直接由nginx负责 location / { root /some/path; index index.html index.htm; } }
, access http://example.com:8080/ as a static resource and http://example.com:8080/api/* as an interface
http://example.com:8080/
http://example.com:8080/api/*
Now that the front and back ends are separated, the stateless model should be accepted. Try other ways to solve the state saving problem.
For example: User information can be returned in the login interface and processed by the front end.
Use nginx as a reverse proxy and map services on different ports to a unified port to achieve cookie sharing
nginx configuration file example:
After, access
http://example.com:8080/
as a static resource andhttp://example.com:8080/api/*
as an interface