1 "use server"
2
3 import { OpenAPI } from "types"
4
5 // Mirror the defaults used by config/index.ts (baseUrl) and next.config.mjs
6 // (basePath) so dev works without every env var set.
7 const baseUrl = process.env.NEXT_PUBLIC_BASE_URL || "http://localhost:3000"
8 const basePath = process.env.NEXT_PUBLIC_BASE_PATH || "/api"
9 const URL = `${baseUrl}${basePath}`
10
11 export async function getBaseSpecs(area: OpenAPI.Area) {
12 try {
13 const res = await fetch(`${URL}/base-specs?area=${area}`, {
14 next: {
15 revalidate: 3000,
16 tags: [area],
17 },
18 }).then(async (res) => res.json())
19
20 return res as OpenAPI.ExpandedDocument
21 } catch (e) {
22 console.error(e)
23 }
24 }