Repository nuxt.js

Use nuxt.js renderer instance for multiple backends

hydroid7
0
hydroid7
commented 10 days ago

I want to use a single instance of nuxtjs renderer to serve multiple webapps.

Basically I want to achieve this setup, where the routing is based on the host header:

 domain1.com----+                   +------+api1
                +--+nuxt js renderer+
 domain2.com----+                   +------+api2

I've tried to configure Nuxt JS Axios Proxy Module like this, but both domains are proxied to the first upstream domain1.com

  proxy: {
    'http://domain1.com/api': {
      target: 'http://localhost:8888'
    },
    'http://domain2.com/api': {
      target: 'http://localhost:8889'
    }
  }

Solutions I struggled so far:

  • Use nuxt proxy. See above.
  • Use Nginx as proxy. I tried to redirect all requests to the main domain, i.e. domain1.com and nginx takes care about proxying requests to api, but I have no idea how to tell nuxt to proxy request to the currentHost

Can you suggest any solution for use cases like this?
Thank you very much.

0
Informations
QuestionUnresolved
#c7530 - Created 10 days ago