PHP中文网2017-04-17 15:07:54
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.
天蓬老师2017-04-17 15:07:54
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;
}
}
After , access http://example.com:8080/
as a static resource and http://example.com:8080/api/*
as an interface