Docs · Nuxt

Frameworks

Nuxt

Routing through a Nuxt server route, with the key in runtime config.

Example

server/api/route.get.tsts
1// server/api/route.get.ts — routing through your Nuxt server2// (runtimeConfig.orviaApiKey from NUXT_ORVIA_API_KEY).3// Call it from a page with: await $fetch("/api/route", { query: { from, to } })4export default defineEventHandler(async (event) => {5  const { from, to } = getQuery(event);67  return $fetch("https://orviamaps.ir/api/v1/route", {8    query: { from, to }, // "lat,lon"9    headers: { Authorization: `Bearer ${useRuntimeConfig().orviaApiKey}` },10  });11});

Replace YOUR_API_KEY with a key from your account, or read it from an environment variable as shown.