EnverMT
EnverMT
NNuxt
Created by EnverMT on 4/29/2025 in #❓・help
Apollo | graphql | proxy
Backend runs on Sprapi on pm2. Frontend is Nuxt on pm2. Installed Apollo Graphql server to get data from backend. I wanted to proxy localhost:3000/graphql to localhost:1337/graphql. How to correctly proxy, so user will not see backend. User must see that graphql request is going to localhost:3000/graphql, but in reality these request should proxy to localhost:1337/graphql
// https://nuxt.com/docs/api/configuration/nuxt-config
export default defineNuxtConfig({
compatibilityDate: "2024-11-01",
devtools: { enabled: true },
ssr: true,

modules: ["@nuxtjs/apollo", "@nuxt/eslint", "@radya/nuxt-dompurify"],

routeRules: {
"/graphql": {
// prerender: true ,
redirect: "https://10.1.20.208/graphql",
},
},

apollo: {
clients: {
default: {
httpEndpoint: "/graphql",
},
},
},
});
// https://nuxt.com/docs/api/configuration/nuxt-config
export default defineNuxtConfig({
compatibilityDate: "2024-11-01",
devtools: { enabled: true },
ssr: true,

modules: ["@nuxtjs/apollo", "@nuxt/eslint", "@radya/nuxt-dompurify"],

routeRules: {
"/graphql": {
// prerender: true ,
redirect: "https://10.1.20.208/graphql",
},
},

apollo: {
clients: {
default: {
httpEndpoint: "/graphql",
},
},
},
});
5 replies