feat: Custom Server Routes for external backend api
还没有人认领这个 Issue。
评估
- 难度
- 5/5
- 预计耗时
- 一周以上
- 新手友好度
- 30/100
- Issue 类型
- 功能
- 描述清晰度
- 基本清楚
- 活跃度
- 停滞
- 技术栈
- nuxt, typescript
调研方向
首先检查提议的 /server/external/api.ts 入口点,以及现有 Nuxt 服务器路由的配置方式。确定 defineExternalApi、runtimeConfig.apiBase、路由方法、标头、查询参数和 Cookie 将如何结合;完成的标准是可以在 DevTools 中分配和测试外部 API,而无需为每个请求设置单独的服务器路由。
由索引模型根据 Issue 内容生成。
描述
🆒 Your use case
Server routes are amazing for testing api routes quickly but in a lot of use cases we could be using an external backend and we want to be able to assign them and test them directly in the devtools.
🆕 The solution you'd like
A method in the /server directory to assign external api routes with the sole purpose to assign external apis, my suggestion is /server/external/api.ts where we can modify the external backend settings directly inside this file:
export default defineExternalApi((event) => {
const runtimeConfig = useRuntimeConfig()
event.baseUrl = runtimeConfig.apiBase
return {
'/login': {
method: 'POST',
headers: [...], // these are defaults that are modifiable
queries: [...],
cookies: [...]
},
'/logout': {
method: 'GET',
...
}
}
})
for compatibility we could build a tool to convert directly from postman or .rest files etc.
🔍 Alternatives you've considered
Implementing a nuxt server route for every single request and routing everything through it but it's absolutely not efficient.
ℹ️ Additional info
I believe this will heavily improve the development experience across teams and if some documentation was able to be implemented directly into them too it would mean that any api service can build with whatever accepted format and plug the documentation directly into nuxt which would make it such a powerful tool for teams and individuals.
- 主要语言
- TypeScript
- 星标
- 3.3k
- 派生
- 214
- 平均合并
- 19 小时 45 分钟
- 30 天内合并 PR
- 12
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
nuxt/devtools 的其他 Issue
-
bug
难度 2/5 1-3 小时 新手友好度 72/100
-
bug
难度 2/5 1-3 小时 新手友好度 72/100
-
bug
难度 3/5 1-2 天 新手友好度 68/100
-
enhancement
难度 5/5 一周以上 新手友好度 25/100
-
bug needs reproduction
难度 4/5 3-5 天 新手友好度 38/100
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 70/100
-
难度 2/5 1-3 小时 新手友好度 75/100
mksglu/context-mode#1200 ·
-
难度 2/5 1-3 小时 新手友好度 75/100
jaegertracing/jaeger-ui#4506 ·
-
area:desktop area:ui bug platform:macos
难度 2/5 1-3 小时 新手友好度 75/100
anthropics/claude-code#96687 ·
-
good first issue
难度 1/5 1 小时以内 新手友好度 95/100
AOSSIE-Org/DebateAI#582 · 2 条评论 ·