I currently have my angular application running within a docker container, exposed on port 83. Additionally, I have a separate spring-boot rest app running inside another docker container, exposed on port 8083.
On the host server, there is an Nginx server configured to reroute all requests using the following configuration:
server {
listen 80;
server_name mydomain.com;
location / {
proxy_pass http://127.0.0.1:83;
}
}
server {
listen 80;
server_name rest.mydomain.com;
location / {
proxy_pass http://127.0.0.1:8083;
}
}
According to this configuration, any request using mydomain.com will be directed to my Angular 6 app, while requests using rest.mydomain.com will be directed to my spring-boot rest app.
The index page of my angular app features a search form that triggers the Routing module to open a search result page.
The content of my app-routing.module.ts file is as follows:
import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';
import { HomePgComponent } from './home-pg/home-pg.component';
import { ResultsPgComponent } from './results-pg/results-pg.component';
const routes: Routes = [
{ path: "", component: HomePgComponent },
{ path: "search", component: ResultsPgComponent }
];
@NgModule({
imports: [RouterModule.forRoot(
routes,
{ enableTracing: true }
)],
exports: [
RouterModule
]
})
export class AppRoutingModule { }
export const RoutingComponents = [
HomePgComponent,
ResultsPgComponent
];
The trigger function on my search form looks like this:
onSearchBtnClk(el) {
if (el.value.length > 0) {
console.log(">>> SEARCH ARGS = " + el.value);
this.router.navigate(['/search'], { queryParams: { q: el.value }});
this.newArgsEmitter.emit(el.value);
}
}
Currently, everything functions correctly - when I click the search button, my Angular app successfully opens the search result page and displays the results. However, I am encountering an issue when I click the REFRESH button in the browser. Instead of displaying the search page results, it shows a 404 error page. Why does this happen?
Any advice or insight would be greatly appreciated. Thank you.