我无法处理GET请求,该请求位于&text; html'类型。
app.js
...
const express = require('express');
const app = express();
const bodyParser = require('body-parser');
app.use(express.json());
//Tried these also
//app.use(bodyParser.json())
//app.use(bodyParser.text())
//app.use(bodyParser.text({type:'text/*'}))
require('./routes')(app);
...
routes.js
const Api= require('./api');
module.exports = (app) => {
app.get('/wa', Api.handleRequest);
}
请求:
Request URL:http://localhost:8081/wa?action_name=dosomething&idsite=1&tp=1&aq=42215
Request Method:GET
Status Code:404 Not Found
Remote Address:[::1]:8081
Referrer Policy:no-referrer-when-downgrade
请求标题:
Accept:image/webp,image/apng,image/*,*/*;q=0.8
Accept-Encoding:gzip, deflate, br
Accept-Language:en-US,en;q=0.9,tr;q=0.8
Cache-Control:no-cache
Connection:keep-alive
Cookie:....
Host:localhost:8081
Pragma:no-cache
Referer:http://localhost:8080/dashboard
User-Agent:Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/62.0.3202.94 Safari/537.36
如你所见,我得到了404.提前致谢。
答案 0 :(得分:1)
当我将路线和请求网址更改为'/ wa.js'时,它可以正常工作。作为回应,我发送一个空白的GIF。虽然很奇怪..
请求强>
Request URL:http://localhost:8081/wa.js?action_name=dosomething&idsite=1&tp=1&aq=42215
<强> routes.js 强>
...
app.get('/wa.js', Api.handleRequest);
...