四、Nodejs 登录

75 阅读1分钟

Cookie

image.png

Node.js 解析 cookie

image.png

Node.js 设置 cookie

image.png

Node.js 设置httpOnly 不允许前端 js 修改

image.png

session

使用 cookie 会暴露 username

image.png

image.png

session 使用

const SESSION_DATA={}

image.png

image.png

image.png

image.png

image.png

redis

session 问题

image.png

redis 特点

image.png

redis 安装与使用

安装

端口 brew install redis redis-server 启动 新终端使用 redis-cli
set myname shuangyuelaoshi get myname keys * del myname

使用

image.png

封装

image.png

image.png

调用

image.png

image.png

nginx 代理

nginx 介绍

image.png

nginx 命令

image.png

nginx 安装与下载

下载

brew install nginx

nginx 反向代理

image.png

配置

image.png

server{
        listen 8080;
        location /{
            proxy_pass http://localhost:8001;
        }
        location /api{
            proxy_pass http://localhost:8000;
            proxy_set_header Host $host;
        }
}