You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Postman无法发送POST请求至localhost:8800,求问题排查方案

Postman发送POST请求失败:localhost request not supported 问题排查

我是Postman新手,首次使用时无法发送POST请求,Postman控制台报错:

Error: localhost request not supported
Network Request Headers
User-Agent: PostmanRuntime/7.32.2
Accept: /
Cache-Control: no-cache
Postman-Token: 815c2340-5ac3-4ab4-91be-8d62a5d6333b
Host: localhost:8800
Accept-Encoding: gzip, deflate, br
Connection: keep-alive

后端代码片段

用户注册控制器代码

import User from "../models/user.model.js";

export const register = async (req,res)=> {
    try {
        const newUser = new User(req.body);
        
        await newUser.save();
        res.status(201).send("User has been created.");
    } catch (err) {
        res.status(500).send("Something went wrong!");
    }
};

//export const login = async (req,res)=> {};

//export const logout = async (req,res)=> {};

路由配置代码

import express from "express";
import { register,  } from "../controllers/auth.controller.js";
const router = express.Router();

router.post("/register", register)
//router.post("/login", login)
//router.post("/logout", logout)

export default router;

请求相关截图

请求配置截图
控制台报错截图

排查方向

  • 检查Postman请求URL是否添加了协议前缀(http://或https://),缺失协议会导致Postman无法正确识别localhost请求。
  • 确认本地服务是否在8800端口正常运行,可通过curl http://localhost:8800/register -X POST -H "Content-Type: application/json" -d '{"username":"test"}'测试服务连通性。
  • 检查主Express应用是否正确挂载了auth路由,比如是否存在app.use("/auth", authRouter)这类代码,路由未挂载会导致请求无法被处理。
  • 查看Postman代理设置(Settings > Proxy),若开启全局代理,尝试关闭后重试,代理可能拦截localhost请求。
  • 可尝试在后端添加CORS中间件(npm install cors后在主app中引入app.use(cors())),排除跨域相关隐性问题。

内容的提问来源于stack exchange,提问作者Masrur.18

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.24 13:25:07