nuxt-community / proxy-module

The one-liner node.js http-proxy middleware solution for Nuxt 2 using http-proxy-middleware

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Using runtime environment variables

jessielaf opened this issue · comments

Hi,

I am working on a new deployment structure using docker. The problem I am having now is that the target option has to be passed on build and not on runtime.

Nuxt now has the publicRuntimeConfig and privateRuntimeConfig but I have not found a way to use these in the nuxt.config.js. Is there a way to do this? Another option maybe to make target a function which in which the ctx gets passed. But of course this functionality is from http-proxy-middleware and is not functionality (I think) this library can change.

I am also going to create a ticket at the nuxt repo but I was wondering if there is a solution for this?

I also opened a ticket at Nuxt: #8635

Hi @jessielaf. Actually you do not need runtimeConfig feature to change proxy targets since nuxt.config is always loaded with updated environment variables which can directly use like target: process.env.PROXY_TARGET

@pi0 I tested it and it didn't work. Well after your comment I tried it again and it seemed like it did work. Sorry for your trouble!