3

I have a angular 6 app with multiple projects, i configure my rewrite rules to the following:

"rewrites": [
  {
    "source": "/ticket/**",
    "destination": "/ticket-app/index.html"
  },
  {
    "source": "/client/**",
    "destination": "/client-app/index.html"
  },
  {
    "source": "/admin/**",
    "destination": "/admin-app/index.html"
  }
],

The application is deployed without error, but when go to the urls, the applications not working correctly, the .js are no load for the browser. When you viisit the url of the .js is get only the .html page.I can see the following error in the developer console:

Chrome console Chrome console

All get request to .js files and .css files always return index.html page, i try other rewrite formats like this:

"rewrites": [
  {
    "source": "/ticket/**",
    "destination": "/ticket-app/**"
  },
  {
    "source": "/client/**",
    "destination": "/client-app/"
  },
  {
    "source": "/admin/**",
    "destination": "/admin-app/*"
  }
],

But no working. I build the app with the command:

ng build ticket-app --prod --base-href '/ticket/'

thanks

Roberto
  • 169
  • 9

1 Answers1

0

You also need to add deployUrl. There are 2 options

1) add --deploy-url param when building the application

ng build ticket-app --prod --base-href '/ticket/' 

2) Add configuration in angular.json for each application

"build": {
          "options": {
            ...
            "baseHref": "/ticket/",
            "deployUrl": "/ticket/"
          },
 ...
}
Kalyan
  • 1,781
  • 11
  • 15