Next.js / Backend APIs

Step 16 of 24

Reenviar la configuración regional a las API de backend

Cuando un frontend de Next.js llama a un backend independiente, envía la configuración regional Altified activa con la solicitud para que los SDK del backend puedan devolver datos traducidos.

Use altifiedFetch in your shared API client. It forwards the current locale with Accept-Language, so a Django backend using django_altified receives the same language as the current Next route.

api/client.js
import { altifiedFetch } from "@altified/next/fetch"; const response = await altifiedFetch(BACKEND_URL + path, { credentials: "include", });

If your app uses Axios, attach the Altified interceptor to the shared Axios instance instead.

api.js
import axios from "axios"; import { altifiedAxiosInterceptor } from "@altified/next/axios"; const api = axios.create({ baseURL: BACKEND_URL, withCredentials: true, }); altifiedAxiosInterceptor(api);

Use one shared client

You should not edit every request. Add the helper once to the central fetch wrapper or Axios instance that your app already uses for backend calls.