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;











share|improve this question























  • 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














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;











share|improve this question























  • 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












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;











share|improve this question















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






share|improve this question















share|improve this question













share|improve this question




share|improve this question








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
















  • 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

















active

oldest

votes











Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















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






























active

oldest

votes













active

oldest

votes









active

oldest

votes






active

oldest

votes















draft saved

draft discarded
















































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.




draft saved


draft discarded














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





















































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







這個網誌中的熱門文章

Barbados

How to read a connectionString WITH PROVIDER in .NET Core?

Node.js Script on GitHub Pages or Amazon S3