Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

feat: Custom Server Routes for external backend api

Đang mở
#885 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Đánh giá

Độ khó
5/5
Thời gian dự kiến
Hơn một tuần
Mức phù hợp với người mới
30/100
Loại issue
Tính năng
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Đình trệ
Công nghệ
nuxt, typescript

Hướng nghiên cứu

Bắt đầu bằng cách kiểm tra entry point /server/external/api.ts được đề xuất và cách các server route hiện có của Nuxt được cấu hình. Xác định cách defineExternalApi, runtimeConfig.apiBase, các method của route, header, query và cookie sẽ kết hợp với nhau; hoàn thành có nghĩa là có thể gán và kiểm thử các API bên ngoài trong DevTools mà không cần một server route riêng cho từng request.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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.

Ngôn ngữ chính
TypeScript
Star
3.3k
Fork
214
Merge trung bình
19 giờ 45 phút
Pull request đã merge (30 ngày)
12

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của nuxt/devtools

Tất cả issue của nuxt/devtools

Issue tương tự

Thêm issue về TypeScript

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.