Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

feat: Custom Server Routes for external backend api

未关闭
#885 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
5/5
预计耗时
一周以上
新手友好度
30/100
Issue 类型
功能
描述清晰度
基本清楚
活跃度
停滞
技术栈
nuxt, typescript

调研方向

首先检查提议的 /server/external/api.ts 入口点,以及现有 Nuxt 服务器路由的配置方式。确定 defineExternalApi、runtimeConfig.apiBase、路由方法、标头、查询参数和 Cookie 将如何结合;完成的标准是可以在 DevTools 中分配和测试外部 API,而无需为每个请求设置单独的服务器路由。

由索引模型根据 Issue 内容生成。

描述

enhancement
🆒 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

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

nuxt/devtools 的其他 Issue

查看 nuxt/devtools 的全部 Issue

相似的 Issue

更多 TypeScript Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。