Angular 5 without hash true configuration in routing build is not working in ngnix
up vote
-2
down vote
favorite
I have the angular 5 application which is running locally its working fine with hash true configuration in routing module.
When I am building the prod build deployed in nginx I am trying to get the router url like below its throwing 404 error
http://localhost:4200/dashboard/empty/61
But the same is working fine in local ng serve command.
I am confused what I am missing here. Any suggestion should be appricated.
The routing file is given below.
`import NgModule from '@angular/core';
import RouterModule, Routes from '@angular/router';
import LoadComponent from './load/load.component';
import ListComponent from './list/list.component';
import AuthGuardService from './services/auth-guard.service';
import PathLocationStrategy, LocationStrategy, HashLocationStrategy from '@angular/common';
const appRoutes: Routes = [
path: '',
children: ,
,
path: 'dashboard/empty/:id',
component: LoadComponent,
canActivate: [AuthGuardService]
,
path: 'list',
component: ListComponent
];
@NgModule(
imports: [RouterModule.forRoot(appRoutes)],
exports: [RouterModule],
)
export class AppRoutingModule `
Build Comment is ng build --prod
The ngnix config is added below.
server
listen 81 default_server;
listen [::]:81 default_server ipv6only=on;
root /var/www/html;
index index.html index.htm;
# Make site accessible from http://localhost/
server_name http://0.0.0.0:81;
location /loadserver
proxy_pass http://0.0.0.0:8094/loadserver;
angular nginx
|
show 5 more comments
up vote
-2
down vote
favorite
I have the angular 5 application which is running locally its working fine with hash true configuration in routing module.
When I am building the prod build deployed in nginx I am trying to get the router url like below its throwing 404 error
http://localhost:4200/dashboard/empty/61
But the same is working fine in local ng serve command.
I am confused what I am missing here. Any suggestion should be appricated.
The routing file is given below.
`import NgModule from '@angular/core';
import RouterModule, Routes from '@angular/router';
import LoadComponent from './load/load.component';
import ListComponent from './list/list.component';
import AuthGuardService from './services/auth-guard.service';
import PathLocationStrategy, LocationStrategy, HashLocationStrategy from '@angular/common';
const appRoutes: Routes = [
path: '',
children: ,
,
path: 'dashboard/empty/:id',
component: LoadComponent,
canActivate: [AuthGuardService]
,
path: 'list',
component: ListComponent
];
@NgModule(
imports: [RouterModule.forRoot(appRoutes)],
exports: [RouterModule],
)
export class AppRoutingModule `
Build Comment is ng build --prod
The ngnix config is added below.
server
listen 81 default_server;
listen [::]:81 default_server ipv6only=on;
root /var/www/html;
index index.html index.htm;
# Make site accessible from http://localhost/
server_name http://0.0.0.0:81;
location /loadserver
proxy_pass http://0.0.0.0:8094/loadserver;
angular nginx
angular.io/guide/…
– JB Nizet
Nov 11 at 14:50
Can you show your routing module and the command you are using to build
– Mahi
Nov 11 at 14:57
@Ahmadmnzr I have edited my question added the routing file please see that
– PrabakarK
Nov 11 at 15:02
JB nizet provided your answer..
– MikeOne
Nov 11 at 15:22
Should I add this line in ngnix config file try_files $uri $uri/ /index.html;
– PrabakarK
Nov 11 at 15:28
|
show 5 more comments
up vote
-2
down vote
favorite
up vote
-2
down vote
favorite
I have the angular 5 application which is running locally its working fine with hash true configuration in routing module.
When I am building the prod build deployed in nginx I am trying to get the router url like below its throwing 404 error
http://localhost:4200/dashboard/empty/61
But the same is working fine in local ng serve command.
I am confused what I am missing here. Any suggestion should be appricated.
The routing file is given below.
`import NgModule from '@angular/core';
import RouterModule, Routes from '@angular/router';
import LoadComponent from './load/load.component';
import ListComponent from './list/list.component';
import AuthGuardService from './services/auth-guard.service';
import PathLocationStrategy, LocationStrategy, HashLocationStrategy from '@angular/common';
const appRoutes: Routes = [
path: '',
children: ,
,
path: 'dashboard/empty/:id',
component: LoadComponent,
canActivate: [AuthGuardService]
,
path: 'list',
component: ListComponent
];
@NgModule(
imports: [RouterModule.forRoot(appRoutes)],
exports: [RouterModule],
)
export class AppRoutingModule `
Build Comment is ng build --prod
The ngnix config is added below.
server
listen 81 default_server;
listen [::]:81 default_server ipv6only=on;
root /var/www/html;
index index.html index.htm;
# Make site accessible from http://localhost/
server_name http://0.0.0.0:81;
location /loadserver
proxy_pass http://0.0.0.0:8094/loadserver;
angular nginx
I have the angular 5 application which is running locally its working fine with hash true configuration in routing module.
When I am building the prod build deployed in nginx I am trying to get the router url like below its throwing 404 error
http://localhost:4200/dashboard/empty/61
But the same is working fine in local ng serve command.
I am confused what I am missing here. Any suggestion should be appricated.
The routing file is given below.
`import NgModule from '@angular/core';
import RouterModule, Routes from '@angular/router';
import LoadComponent from './load/load.component';
import ListComponent from './list/list.component';
import AuthGuardService from './services/auth-guard.service';
import PathLocationStrategy, LocationStrategy, HashLocationStrategy from '@angular/common';
const appRoutes: Routes = [
path: '',
children: ,
,
path: 'dashboard/empty/:id',
component: LoadComponent,
canActivate: [AuthGuardService]
,
path: 'list',
component: ListComponent
];
@NgModule(
imports: [RouterModule.forRoot(appRoutes)],
exports: [RouterModule],
)
export class AppRoutingModule `
Build Comment is ng build --prod
The ngnix config is added below.
server
listen 81 default_server;
listen [::]:81 default_server ipv6only=on;
root /var/www/html;
index index.html index.htm;
# Make site accessible from http://localhost/
server_name http://0.0.0.0:81;
location /loadserver
proxy_pass http://0.0.0.0:8094/loadserver;
angular nginx
angular nginx
edited Nov 11 at 15:31
asked Nov 11 at 14:48
PrabakarK
67
67
angular.io/guide/…
– JB Nizet
Nov 11 at 14:50
Can you show your routing module and the command you are using to build
– Mahi
Nov 11 at 14:57
@Ahmadmnzr I have edited my question added the routing file please see that
– PrabakarK
Nov 11 at 15:02
JB nizet provided your answer..
– MikeOne
Nov 11 at 15:22
Should I add this line in ngnix config file try_files $uri $uri/ /index.html;
– PrabakarK
Nov 11 at 15:28
|
show 5 more comments
angular.io/guide/…
– JB Nizet
Nov 11 at 14:50
Can you show your routing module and the command you are using to build
– Mahi
Nov 11 at 14:57
@Ahmadmnzr I have edited my question added the routing file please see that
– PrabakarK
Nov 11 at 15:02
JB nizet provided your answer..
– MikeOne
Nov 11 at 15:22
Should I add this line in ngnix config file try_files $uri $uri/ /index.html;
– PrabakarK
Nov 11 at 15:28
angular.io/guide/…
– JB Nizet
Nov 11 at 14:50
angular.io/guide/…
– JB Nizet
Nov 11 at 14:50
Can you show your routing module and the command you are using to build
– Mahi
Nov 11 at 14:57
Can you show your routing module and the command you are using to build
– Mahi
Nov 11 at 14:57
@Ahmadmnzr I have edited my question added the routing file please see that
– PrabakarK
Nov 11 at 15:02
@Ahmadmnzr I have edited my question added the routing file please see that
– PrabakarK
Nov 11 at 15:02
JB nizet provided your answer..
– MikeOne
Nov 11 at 15:22
JB nizet provided your answer..
– MikeOne
Nov 11 at 15:22
Should I add this line in ngnix config file try_files $uri $uri/ /index.html;
– PrabakarK
Nov 11 at 15:28
Should I add this line in ngnix config file try_files $uri $uri/ /index.html;
– PrabakarK
Nov 11 at 15:28
|
show 5 more comments
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53249861%2fangular-5-without-hash-true-configuration-in-routing-build-is-not-working-in-ngn%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
angular.io/guide/…
– JB Nizet
Nov 11 at 14:50
Can you show your routing module and the command you are using to build
– Mahi
Nov 11 at 14:57
@Ahmadmnzr I have edited my question added the routing file please see that
– PrabakarK
Nov 11 at 15:02
JB nizet provided your answer..
– MikeOne
Nov 11 at 15:22
Should I add this line in ngnix config file try_files $uri $uri/ /index.html;
– PrabakarK
Nov 11 at 15:28