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

512
Visualizações
Angular application in a subfolder routing issue

It is a bit of weird situation but we have to structure the two angular app as below.

App1 being the main angular app situated at the root and other angular app is in a subfolder.

  • http://www.example.com - App1
  • http://www.example.com/subfolder - App2

All is working well except for the routing in App2 since it is overridden by the routes config in Main app.

I am able to use the command below to build/deploy and appears to be working for App2 (subfolder)

ng build --prod --base-href /subfolder/ --deploy-url /subfolder/

App1 is configured to have unknown routes redirected to a 404 page like below

{ path: '**', redirectTo: '/404' }

The issue with if I refresh the page on App2. it got redirected to the 404 page defined in App1. eg. http://www.example.com/subfolder/route1

How can I tell angular in App1 to ignore anything under subfolder and use its own angular routes in App2?

over 4 years ago · Santiago Trujillo
2 Respostas
Responde à pergunta

0

I'm not sure if this will work or if it is helpful at all. But when using a base href like:

<base href="/subfolder/" />

I had to create a proxy configuration e.g.:

proxy.conf.json

{
  "/subfolder/*": {
    "target": "http://localhost:4200",
    "secure": false,
    "logLevel": "debug",
    "changeOrigin": true,
    "pathRewrite": {
      "^/subfolder": ""
    }
  }
}

And serve it using this proxy configuration:

ng serve --proxy-config proxy.conf.json

In angular.json you can also add proxy configurations:

"build": {
  "builder": "@angular-devkit/build-angular:browser",
  "options": {
    "proxyConfig": "proxy.conf.json"
  }
}
...
"serve": {
  "builder": "@angular-devkit/build-angular:dev-server",
  "options": {
    "proxyConfig": "proxy.conf.json"
  }
}

You can find more information here.

over 4 years ago · Santiago Trujillo Relatório

0

I had the same problem in one project and handled this issue by using <a href=""></a> instead routerLink for routing between projects.

Another way is using Angular workspace to merge all projects in one.

over 4 years ago · Santiago Trujillo 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