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
相关产品推荐
相关产品推荐

