当我在Chrome中向我的NodeJS Fastify服务器发出POST
请求时,Chrome的“网络”标签会显示一个发布请求:
但是,Fastify记录两个请求,每个请求都有一个唯一的请求ID:
现在,疯狂的是,当我在Firefox中执行相同的请求时,Fastify仅记录一个请求...这是Chrome问题还是Fastify / NodeJS?
前端POST
请求:
const response = await fetch('/api/signupForm', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({
foo: bar,
})
}).then(response => response.json()).catch(error => {
...
});
强化请求
fastify.post('/signupForm', {
body: {
type: 'object',
required: ['foo'],
properties: {
foo: {
type: 'string'
}
}
},
//Output Serialization
schema: {
response: {
200: {
type: 'object',
properties: {
success: {
type: 'boolean'
}
}
}
}
},
}, async (req, reply) => {
console.log('route started..............................................................');
...