Is it necessary to use Nuxt Server as an intermediary between my external Django API and the Nuxt 3 frontend in SSR mode?

I am developing a SaaS application using a backend architecture with a Django REST API and a PostgreSQL database, while the frontend uses Nuxt 3 with TypeScript, Tailwind, and TanStack Query for API request management. I have enabled Server-Side Rendering (SSR) by setting ssr: true in the nuxt.config.ts file :

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code>export default defineNuxtConfig({
ssr: true,
})
</code>
<code>export default defineNuxtConfig({ ssr: true, }) </code>
export default defineNuxtConfig({
    ssr: true,
})

In my current architecture, I have a server/api/ directory within my Nuxt 3 application containing multiple files that represent endpoints to interact with the Django API. For instance, I have a file server/api/projects/index.ts that points to the Django endpoint /api/projects/ to fetch all projects.

Nuxt Server Integration:

Nuxt Server Directory Structure:

server/api/projects/index.ts : Points to the Django endpoint /api/projects/ to fetch all projects.
server/api/projects/[id].get.ts : Fetches a project by its ID from /api/projects/detail/${projectId}/.

API Interaction Logic:

These endpoints are used within a service handler (api/projects.api.ts) that provides functions like getAllProjects, getProjectById, and deleteProjectById.

Composable (useProjects.ts):

The composable useProjects.ts uses the functions in api/projects.api.ts to manage project data and interact with the Nuxt Server endpoints in server/api/projects/. It leverages useQuery from TanStack Query for efficient state management.

Question :

Is it necessary to have an intermediary Nuxt server between the Nuxt 3 frontend and an external Django API? Does this provide any specific benefits for Server-Side Rendering (SSR), or can the Nuxt 3 frontend directly interact with the Django API while maintaining SSR features?

Thank you for your help!

Application Structure :

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code>frontend/
├─ api/ # Functions to call the API server Nuxt 3 (server/api/)
│ └─ projects.api.ts
├─ app.vue
├─ assets/
│ └─ css/
│ └─ tailwind.css
├─ composables/ # Composables to call functions in api/projects.api.ts
│ └─ useProjects.ts # and share data between components
├─ nuxt.config.ts
├─ pages
│ ├─ ecowall/
│ │ ├─ conception
│ │ │ └─ [projectId]
│ │ │ └─ paroi
│ │ │ ├─ [paroiId].vue
│ │ │ └─ new-paroi.vue
│ │ ├─ index.vue
│ │ └─ projects
│ │ ├─ [projectId].vue
│ │ └─ index.vue # I use my composables useProjects.ts here to get all projects
│ └─ index.vue
├─ plugins
│ └─ vue-query.ts
├─ server/ # Intermediary server to call the Django API endpoints
│ ├─ api/
│ │ ├─ projects/
│ │ │ ├─ [id].delete.ts
│ │ │ ├─ [id].get.ts
│ │ │ ├─ create.post.ts
│ │ │ └─ index.ts
│ └─ tsconfig.json
└─ tsconfig.json
</code>
<code>frontend/ ├─ api/ # Functions to call the API server Nuxt 3 (server/api/) │ └─ projects.api.ts ├─ app.vue ├─ assets/ │ └─ css/ │ └─ tailwind.css ├─ composables/ # Composables to call functions in api/projects.api.ts │ └─ useProjects.ts # and share data between components ├─ nuxt.config.ts ├─ pages │ ├─ ecowall/ │ │ ├─ conception │ │ │ └─ [projectId] │ │ │ └─ paroi │ │ │ ├─ [paroiId].vue │ │ │ └─ new-paroi.vue │ │ ├─ index.vue │ │ └─ projects │ │ ├─ [projectId].vue │ │ └─ index.vue # I use my composables useProjects.ts here to get all projects │ └─ index.vue ├─ plugins │ └─ vue-query.ts ├─ server/ # Intermediary server to call the Django API endpoints │ ├─ api/ │ │ ├─ projects/ │ │ │ ├─ [id].delete.ts │ │ │ ├─ [id].get.ts │ │ │ ├─ create.post.ts │ │ │ └─ index.ts │ └─ tsconfig.json └─ tsconfig.json </code>
frontend/
├─ api/                         # Functions to call the API server Nuxt 3 (server/api/)
│  └─ projects.api.ts
├─ app.vue
├─ assets/
│  └─ css/
│     └─ tailwind.css
├─ composables/                 # Composables to call functions in api/projects.api.ts
│  └─ useProjects.ts            # and share data between components
├─ nuxt.config.ts
├─ pages
│  ├─ ecowall/
│  │  ├─ conception
│  │  │  └─ [projectId]
│  │  │     └─ paroi
│  │  │        ├─ [paroiId].vue
│  │  │        └─ new-paroi.vue
│  │  ├─ index.vue
│  │  └─ projects
│  │     ├─ [projectId].vue
│  │     └─ index.vue           # I use my composables useProjects.ts here to get all projects
│  └─ index.vue
├─ plugins
│  └─ vue-query.ts
├─ server/                     # Intermediary server to call the Django API endpoints
│  ├─ api/
│  │  ├─ projects/
│  │  │  ├─ [id].delete.ts
│  │  │  ├─ [id].get.ts
│  │  │  ├─ create.post.ts
│  │  │  └─ index.ts
│  └─ tsconfig.json
└─ tsconfig.json

I have implemented an intermediary Nuxt server to act as a bridge between the Nuxt 3 frontend and the external Django API. My expectation was that this intermediary layer would improve performance, ensure security, and enhance Server-Side Rendering (SSR). However, I’m uncertain if this approach is necessary.

What I tried:

  • I created several API endpoints in the server/api directory of my Nuxt 3 application that directly point to the Django API endpoints:

server/api/projects/index.ts points to /api/projects/.
server/api/projects/[id].get.ts points to /api/projects/detail/${projectId}/.

  • I created a service handler (api/projects.api.ts) that provides functions to interact with these Nuxt server endpoints.

  • I used a composable (useProjects.ts) to manage project data and interact with the Nuxt server endpoints via TanStack Query.

What I expected:

Improved performance due to better caching and SSR benefits.
Enhanced security since the Nuxt server acts as an intermediary between the frontend and the Django API.

What actually happened:

The setup works fine, but it adds complexity to the architecture.
I’m not sure if this intermediary Nuxt server is necessary or if the Nuxt 3 frontend can directly interact with the external Django API while maintaining SSR features.
Therefore, I would like to confirm whether this approach provides any specific benefits for SSR or if a direct connection between the frontend and the Django API is sufficient.

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật