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

问题描述

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

enter image description here

@H_404_3@

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

enter image description here

@H_404_3@

现在,疯狂的是,当我在Firefox中执行相同的请求时,Fastify仅记录一个请求...这是Chrome问题还是Fastify / NodeJS?@H_404_3@

前端POST请求:@H_404_3@

            const response = await fetch('/api/signupForm',{
                method: 'POST',headers: {
                    'Content-Type': 'application/json'
                },body: JSON.stringify({
                    foo: bar,})
            }).then(response => response.json()).catch(error => {
                ...
            });

强化请求@H_404_3@

    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..............................................................');

...

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)