拨开荷叶行,寻梦已然成。仙女莲花里,翩翩白鹭情。
IMG-LOGO
主页 文章列表 无法在GET请求中接收自变量,openstf-nodejs

无法在GET请求中接收自变量,openstf-nodejs

白鹭 - 2022-03-01 2154 0 0

我遇到了一个奇怪的问题:在用邮递员发送的请求中,nodejs无法接收自变量。

请帮帮我,这个问题困扰了我好几天了,谢谢。

以下档案来自openstf项目: https://github.com/openstf/stf/blob/master/lib/units/auth/mock.js

mock.js :

      // I am create a new reqeuest handler
      app.get('/auth/mock/', function(req, res) {
        var token = req.query.access_token
        if(!token) {
          console.log('*********mock.js----app.get(/auth/mock)***token is null*****')
          console.dir(req)
          res.redirect('a.com')
        }else{
          console.log('*********mock.js----app.get(/auth/mock)**')
          res.status(200)
            .json({
              success: true
              , redirect: urlutil.addParams(options.appUrl, {
                jwt: token
              })
            })
        }
      })

邮递员: 在此处输入图片说明

安慰:


2021-12-27T12:10:17.445557755Z *********mock.js----app.get(/auth/mock)***token is null*****
....
2021-12-27T12:10:17.498524013Z   baseUrl: '',
2021-12-27T12:10:17.498540313Z   originalUrl: '/auth/mock/',
2021-12-27T12:10:17.498556313Z   _parsedUrl: 
2021-12-27T12:10:17.498571913Z    Url {
2021-12-27T12:10:17.498587413Z      protocol: null,
2021-12-27T12:10:17.498602913Z      slashes: null,
2021-12-27T12:10:17.498618513Z      auth: null,
2021-12-27T12:10:17.498634113Z      host: null,
2021-12-27T12:10:17.498649813Z      port: null,
2021-12-27T12:10:17.498665413Z      hostname: null,
2021-12-27T12:10:17.498681114Z      hash: null,
2021-12-27T12:10:17.498699114Z      search: null,
2021-12-27T12:10:17.498714914Z      query: null,
2021-12-27T12:10:17.498825715Z      pathname: '/auth/mock/',
2021-12-27T12:10:17.498845515Z      path: '/auth/mock/',
2021-12-27T12:10:17.498862115Z      href: '/auth/mock/',
2021-12-27T12:10:17.498877915Z      _raw: '/auth/mock/' },
2021-12-27T12:10:17.498893515Z   params: {},
2021-12-27T12:10:17.498909115Z   query: {},
....
2021-12-27T12:10:17.477325069Z   headers: 
2021-12-27T12:10:17.477340870Z    { host: '192.168.8.131:7100',
2021-12-27T12:10:17.477356470Z      'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/94.0.4606.81 Safari/537.36',
2021-12-27T12:10:17.477372470Z      'upgrade-insecure-requests': '1',
2021-12-27T12:10:17.477388270Z      referer: 'http://192.168.8.131:7100//auth/mock?aa=9999999',
2021-12-27T12:10:17.477404270Z      cookie: 'ssid=eyJqd3QiOnsiZW1haWwiOiJjaGVucnVpeGlANDM5OWluYy5jb20iLCJuYW1lIjoiY2hlbnJ1aXhpIn0sImNzcmZTZWNyZXQiOiJsXzB6VEJ5VUdSMUZpM21ZeVVPdnVVMzYifQ==; ssid.sig=NNFfR9rcuBXMOvIOoaSokTwe6Uw; XSRF-TOKEN=CnI0l5Xy-P4fP1UxAcRgWARJJ-I59bY5YJjo',
2021-12-27T12:10:17.477420370Z      connection: 'close',
2021-12-27T12:10:17.477436170Z      'accept-language': 'zh-CN',
2021-12-27T12:10:17.477451670Z      'accept-encoding': 'gzip, deflate, br',
2021-12-27T12:10:17.477467370Z      accept: '*/*' },
2021-12-27T12:10:17.477482870Z   rawHeaders: 
2021-12-27T12:10:17.477498471Z    [ 'host',
2021-12-27T12:10:17.477514071Z      '192.168.8.131:7100',
2021-12-27T12:10:17.477529971Z      'user-agent',
2021-12-27T12:10:17.477546371Z      'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/94.0.4606.81 Safari/537.36',
2021-12-27T12:10:17.477562571Z      'upgrade-insecure-requests',
2021-12-27T12:10:17.477578371Z      '1',
2021-12-27T12:10:17.477594271Z      'referer',
2021-12-27T12:10:17.477610271Z      'http://192.168.8.131:7100//auth/mock?aa=9999999',
2021-12-27T12:10:17.477632572Z      'cookie',
2021-12-27T12:10:17.477649172Z      'ssid=eyJqd3QiOnsiZW1haWwiOiJjaGVucnVpeGlANDM5OWluYy5jb20iLCJuYW1lIjoiY2hlbnJ1aXhpIn0sImNzcmZTZWNyZXQiOiJsXzB6VEJ5VUdSMUZpM21ZeVVPdnVVMzYifQ==; ssid.sig=NNFfR9rcuBXMOvIOoaSokTwe6Uw; XSRF-TOKEN=CnI0l5Xy-P4fP1UxAcRgWARJJ-I59bY5YJjo',
2021-12-27T12:10:17.490127156Z      'connection',
2021-12-27T12:10:17.490145056Z      'close',
2021-12-27T12:10:17.490161156Z      'accept-language',
2021-12-27T12:10:17.490176956Z      'zh-CN',
2021-12-27T12:10:17.490192656Z      'accept-encoding',
2021-12-27T12:10:17.490208256Z      'gzip, deflate, br',
2021-12-27T12:10:17.490223957Z      'accept',
2021-12-27T12:10:17.490239757Z      '*/*' ],
2021-12-27T12:10:17.490255557Z   trailers: {},
2021-12-27T12:10:17.490271257Z   rawTrailers: [],
2021-12-27T12:10:17.490287057Z   upgrade: false,
2021-12-27T12:10:17.490303457Z   url: '/auth/mock/',
2021-12-27T12:10:17.490319457Z   method: 'GET',
2021-12-27T12:10:17.490335257Z   statusCode: null,

uj5u.com热心网友回复:

  
  var app = express()
  var server = Promise.promisifyAll(http.createServer(app))
  //Problems caused by strict mode
  app.set('strict routing', true)
  app.set('case sensitive routing', true)

uj5u.com热心网友回复:

您没有任何名为 的 URL 自变量access_token你给它起了名字aa

将您的网址更改为如下所示: http://192.168.8.131:7100/auth/mock?access_token=9999999

然后当你登录时,req.query.access_token你将拥有的价值9999999

uj5u.com热心网友回复:

192.168.8.131:7100/auth/mock?aa=9999999

我认为网址应该是这个

标签:

0 评论

发表评论

您的电子邮件地址不会被公开。 必填的字段已做标记 *