Nginx获取前端传递的参数

1.前端传递的参数:
const otherSysGetTokenBaseUrl ='http://192.168.50.220:54324/token'
// 解析当前页面的 URL
const urlParams = new URLSearchParams(window.location.search);

  // 获取 'code' 参数的值
  const code = urlParams.get('code');
 // 获取 'host' 参数的值
  const host = urlParams.get('host');
  const originUrl = window.location.origin
  const params = new URLSearchParams({
    code: code,
    host: host,
    url: otherSysGetTokenBaseUrl
  });
  window.location.href = `${originUrl}/#/otherLogin?${params.toString()}`

2.nginx配置文件中配置
location /token {
set $ip $arg_host;
set $code $code;
proxy_pass http://$ip/xxx/getToken?code=$code;
}

posted @ 2025-01-20 11:23  program_keep  阅读(34)  评论(0)    收藏  举报