安全

项目下的数据都是明文传输,如果线上部署的话,建议使用 https

nginx 为例,配置如下:

upstream admin {
    server 127.0.0.1:9504;
}

server {
    listen 443 ssl;
    server_name  admin.test.com;
    root  /wwwroot/txf-client/dist;

    ssl_certificate your_cert_root/admin.pem;           # 证书名
    ssl_certificate_key your_cert_root/admin.key;       # 证书密钥
    ssl_session_timeout 5m; 
    ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4;  #使用此加密套件。
    ssl_protocols TLSv1 TLSv1.1 TLSv1.2;   #使用该协议进行配置。
    ssl_prefer_server_ciphers on; 

    location ^~ /api {

        rewrite ^/api/(.*)$ /$1 break;    

        proxy_set_header Host $http_host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;    

        proxy_cookie_path / "/; secure; HttpOnly; SameSite=strict";

        proxy_pass http://admin;
    }   

    location / {    
        index  index.html;
    }   
}

调整 txf-client 的配置文件,这样的话也不需要配置跨域了

const configOptions = {
    baseURL: "https://admin.test.com/api"
}

results matching ""

    No results matching ""