Chrome向NodeJS服务器发出两个请求

时间:2020-08-28 03:52:36

标签: javascript node.js google-chrome firefox fastify

当我在Chrome中向我的NodeJS Fastify服务器发出POST请求时,Chrome的“网络”标签会显示一个发布请求:

enter image description here

但是,Fastify记录两个请求,每个请求都有一个唯一的请求ID:

enter image description here

现在,疯狂的是,当我在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..............................................................');

...

0 个答案:

没有答案