Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

162
Visualizações
How to deploy adaptive Next Js website on a single domain?

I have built an adaptive website in Next js; Which has two versions one for mobile devices and another for Desktop. Both versions are separate Nextjs projects deployed on two different env. I want to deploy both on the same domain and load the respective versions based on user-agent.

example: www.test.com will load mobile site if found mobile User-Agent else Desktop site

I'm able to load the respective version of the site If I have a sub-domain like "m.test.com" for the mobile version and "test.com" for the desktop version ( for this I have added redirect logic in next.config.js based on User-Agent).

I don't know where to write the logic to render a specific build based on User-Agent on the same domain.

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

If you have two different Node Apps running and want to redirect based on User Agent, you can use nginx's $http_user_agent to rewrite to different ports where your Apps can listen on:

http {
  map $http_user_agent $ua_port {
    default '3000';             # port 3000 for your desktop App
    ~(iPhone|Android) '4000';   # port 4000 for mobile App
  }

  server {
    location / {
        proxy_pass http://localhost:$ua_port;   # proxy_pass to port
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection 'upgrade';
        proxy_set_header Host $host;
        proxy_cache_bypass $http_upgrade;
    }
  }
}
about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda