
Security News
GitHub Actions Pricing Whiplash: Self-Hosted Actions Billing Change Postponed
GitHub postponed a new billing model for self-hosted Actions after developer pushback, but moved forward with hosted runner price cuts on January 1.
一站式 API 模拟与调试平台,让前后端开发零障碍并行
🎯 零配置启动 - 2 行命令搞定一切,秒变 API 服务器
🔄 智能代理 - 无侵入式跨域解决方案,告别 CORS 烦恼
📊 数据生成 - 内置 MockJS,逼真数据一键生成
🎭 Restful API - 自动生成增删改查接口,开发效率翻倍
🕸️ WebSocket 支持 - 完整的实时通信解决方案
📱 可视化管理 - 直观的 Web UI,拖拽式 API 管理
🔄 请求重放 - 历史请求一键重现,调试无忧
🌐 远程调试 - 内置内网穿透,随时随地协作
⚡ 热更新 - 配置修改实时生效,开发体验丝滑
# 全局安装
npm i -g mockm
# 启动示例项目
mm --config
🎉 就这么简单! 你已经拥有了:
💡 提示:
--config参数会创建一个示例配置,包含常用功能演示
问题:前端开发时总是被 CORS 错误困扰?
解决:MockM 让你彻底告别跨域烦恼!
# 最简单的跨域代理
mm proxy=http://your-backend:8080
或者使用配置文件:
module.exports = {
proxy: 'http://your-backend:8080'
}
效果:原本的 http://your-backend:8080/api/users 现在通过 http://127.0.0.1:9000/api/users 访问,自动处理跨域!
module.exports = {
api: {
'/my/awesome/api': {
message: '我的第一个 API',
data: { success: true }
}
}
}
立即可用:http://127.0.0.1:9000/my/awesome/api
想要一个完整的博客系统?只需要:
module.exports = {
db: {
posts: [
{ id: 1, title: '我的第一篇博客', content: '使用 MockM 真的太简单了!' }
]
}
}
瞬间获得:
GET /posts - 获取所有文章GET /posts/1 - 获取指定文章POST /posts - 创建新文章PUT /posts/1 - 更新文章DELETE /posts/1 - 删除文章GET /posts?q=关键词 - 搜索文章module.exports = util => ({
db: {
users: util.libObj.mockjs.mock({
'data|20-50': [{
'id|+1': 1,
name: '@cname', // 随机中文姓名
email: '@email', // 随机邮箱
avatar: '@image("200x200")', // 随机头像
'age|18-65': 1, // 18-65岁随机年龄
address: '@county(true)' // 随机地址
}]
}).data
}
})
需要修改后端返回的数据?轻松搞定:
module.exports = {
proxy: {
'/': 'http://your-backend:8080',
'/api/user': ['data.name', '张三'], // 将用户名改为张三
'/api/status': ['success'] // 直接返回 "success"
}
}
module.exports = {
proxy: {
'/api/slow': {
mid(req, res, next) {
setTimeout(next, 3000) // 延时 3 秒
}
}
}
}
module.exports = {
api: {
'ws /chat'(ws, req) {
ws.send('欢迎进入聊天室!')
ws.on('message', msg => {
ws.send(`回音: ${msg}`)
})
}
}
}
通过 Web UI 轻松管理 API:
module.exports = {
remote: true // 开启远程访问
}
自动生成公网地址,支持:
请求记录详情

API 请求历史

可视化 API 编辑

| 功能特性 | MockM | MockJS | JSON-Server | YApi/Rap2 | Postman Mock | Wiremock | MSW | Faker.js | Apifox |
|---|---|---|---|---|---|---|---|---|---|
| 🚀 零配置启动 | ✅ | ❌ | ✅ | ❌ | ❌ | ❌ | ❌ | ❌ | ❌ |
| 🌐 跨域处理 | ✅ 自动 | ❌ | ❌ | ❌ | ❌ | ✅ | ✅ | ❌ | ❌ |
| 📊 数据生成 | ✅ 内置 MockJS | ✅ | ❌ | ✅ | 🔶 基础 | 🔶 基础 | ✅ | ✅ | ✅ |
| 🔄 Restful API | ✅ 自动生成 | ❌ | ✅ | ❌ | ❌ | ✅ | ❌ | ❌ | ❌ |
| 🕸️ WebSocket | ✅ | ❌ | ❌ | ❌ | ❌ | ❌ | ❌ | ❌ | ❌ |
| 📱 可视化管理 | ✅ | ❌ | ❌ | ✅ | ✅ | 🔶 第三方 | ❌ | ❌ | ✅ |
| 🔄 请求重放 | ✅ | ❌ | ❌ | ❌ | ✅ | ✅ | ❌ | ❌ | ✅ |
| 🌍 远程调试 | ✅ 内置穿透 | ❌ | ❌ | ✅ | ✅ 云端 | ❌ | ❌ | ❌ | ✅ 云端 |
| ⚡ 热更新 | ✅ | ❌ | ✅ | ❌ | ❌ | ✅ | ✅ | ❌ | ❌ |
| 🛠️ 响应拦截 | ✅ | ✅ 仅前端 | ❌ | ❌ | ✅ | ✅ | ✅ | ❌ | ✅ |
| 💻 运行环境 | Node.js | Browser | Node.js | Java/Docker | Cloud | Java | Browser/Node | Node.js | Desktop/Cloud |
| 💰 费用 | 免费 | 免费 | 免费 | 免费/付费 | 免费/付费 | 免费 | 免费 | 免费 | 免费/付费 |
数据生成类工具
API 服务器类工具
测试工具类
平台化工具
| 使用场景 | 推荐工具 | 原因 |
|---|---|---|
| 🚀 快速原型开发 | MockM | 零配置,即开即用 |
| 🧪 前端单元测试 | MSW + Faker.js | 专业测试工具链 |
| 🏢 企业级 API 管理 | YApi + MockM | 文档管理 + 开发调试 |
| ☁️ 团队协作开发 | Apifox / MockM远程模式 | 云端协作 |
| 🎯 Java 后端测试 | WireMock | Java 生态集成 |
| 📊 纯数据生成 | MockJS / Faker.js | 轻量级方案 |
🤔 "MockM 和 MockJS 有什么区别?"
🤔 "MockM 和 JSON-Server 不是一样的吗?"
🤔 "为什么不直接用 Postman Mock?"
🤔 "MSW 看起来也很强大?"
🤔 "企业已经有 YApi/Apifox 了,还需要 MockM 吗?"
| 项目 | 简介 |
|---|---|
| 🎨 Taroify | 移动端组件库 Vant 的 Taro 版本,助力小程序开发 |
| 🎯 wot-design-uni | 基于 Vue3+TS 的 uni-app 组件库,70+ 高质量组件 |
如果你有项目需要在此页面上展示,请告诉我。
本项目基于 MIT 协议开源
Copyright (c) 2017-present, xw
⭐ 如果这个项目对你有帮助,请给我们一个 Star!
FAQs
Analog interface server, painless parallel development of front and back ends.
The npm package mockm receives a total of 131 weekly downloads. As such, mockm popularity was classified as not popular.
We found that mockm demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
GitHub postponed a new billing model for self-hosted Actions after developer pushback, but moved forward with hosted runner price cuts on January 1.

Research
Destructive malware is rising across open source registries, using delays and kill switches to wipe code, break builds, and disrupt CI/CD.

Security News
Socket CTO Ahmad Nassri shares practical AI coding techniques, tools, and team workflows, plus what still feels noisy and why shipping remains human-led.