diff --git a/frontend/src/apollo.ts b/frontend/src/apollo.ts index a4532ad..dba0036 100644 --- a/frontend/src/apollo.ts +++ b/frontend/src/apollo.ts @@ -2,10 +2,11 @@ import { ApolloClient, HttpLink, InMemoryCache } from '@apollo/client'; /** * Felles GraphQL-klient for hele appen. Svar caches i minnet, så samme søk - * to ganger gir bare én forespørsel. URL-en kan overstyres med VITE_GRAPHQL_URL ved deploy. + * to ganger gir bare én forespørsel. URL-en er lik for dev og deploy. + * Se vite.config.ts. */ export const client = new ApolloClient({ - link: new HttpLink({ uri: import.meta.env.VITE_GRAPHQL_URL ?? 'http://localhost:3001' }), + link: new HttpLink({ uri: `${import.meta.env.BASE_URL}graphql` }), cache: new InMemoryCache(), }); diff --git a/frontend/vite.config.ts b/frontend/vite.config.ts index 30aa20c..94079e3 100644 --- a/frontend/vite.config.ts +++ b/frontend/vite.config.ts @@ -6,4 +6,12 @@ import { defineConfig } from 'vite'; export default defineConfig({ base: '/project2/', plugins: [react(), babel({ presets: [reactCompilerPreset()] })], + server: { + proxy: { + '/project2/graphql': { + target: 'http://localhost:3001', + rewrite: () => '/', + }, + }, + }, });