My web app is developed in Angular and backend is developed in .Net Core.
After deploying it in docker on the server, I can visit most of the pages but certain endpoints return 404 not found error. These work fine on localhost.
Backend:
<code>[Authorize(Policy = "IsDesigner")]
[Route("api/[controller]")]
[ApiController]
public class DesignerController : ControllerBase
{
...
[HttpGet("{project}/{loop}")]
public async Task<IActionResult> GetChecklistByLoopAsync(string project, int loop,
CancellationToken cancellationToken)
{
...
}
}
</code>
<code>[Authorize(Policy = "IsDesigner")]
[Route("api/[controller]")]
[ApiController]
public class DesignerController : ControllerBase
{
...
[HttpGet("{project}/{loop}")]
public async Task<IActionResult> GetChecklistByLoopAsync(string project, int loop,
CancellationToken cancellationToken)
{
...
}
}
</code>
[Authorize(Policy = "IsDesigner")]
[Route("api/[controller]")]
[ApiController]
public class DesignerController : ControllerBase
{
...
[HttpGet("{project}/{loop}")]
public async Task<IActionResult> GetChecklistByLoopAsync(string project, int loop,
CancellationToken cancellationToken)
{
...
}
}
Frontend:
<code>getTaskByProject(role:string,project:string):Observable<any> {
const encodedProject = encodeURIComponent(project);
let requiredurl: string;
requiredurl = `${this.apiUrl}/${role}/selection/${encodedProject}`;
const headers = { 'content-type': 'application/json','Authorization':`Bearer ${this.getToken()}`}
return this.http.get(requiredurl, {'headers':headers, observe:'response'});
}
</code>
<code>getTaskByProject(role:string,project:string):Observable<any> {
const encodedProject = encodeURIComponent(project);
let requiredurl: string;
requiredurl = `${this.apiUrl}/${role}/selection/${encodedProject}`;
const headers = { 'content-type': 'application/json','Authorization':`Bearer ${this.getToken()}`}
return this.http.get(requiredurl, {'headers':headers, observe:'response'});
}
</code>
getTaskByProject(role:string,project:string):Observable<any> {
const encodedProject = encodeURIComponent(project);
let requiredurl: string;
requiredurl = `${this.apiUrl}/${role}/selection/${encodedProject}`;
const headers = { 'content-type': 'application/json','Authorization':`Bearer ${this.getToken()}`}
return this.http.get(requiredurl, {'headers':headers, observe:'response'});
}
Error message:
<code>polyfills.4cb30b968c6ea108.js:1
GET https://azeu1.pp.com:4200/api/Designer/selection/AA%20BB%20CC%2FDD%20EE 404 (Not Found)
main.11182255502544c4.js:1
ERROR
wr {headers: lo, status: 404, statusText: 'Not Found', url: 'https://azeu1.pp.com:4200/api/Designer/selection/AA%20BB%20CC%2FDD%20EE', ok: false, …}
error
:
null
headers
:
lo
lazyInit
:
()=> {…}
lazyUpdate
:
null
normalizedNames
:
Map(0) {size: 0}
[[Prototype]]
:
Object
message
:
"Http failure response for https://azeu1.pp.com:4200/api/Designer/selection/AA%20BB%20CC%2FDD%20EE: 404 Not Found"
name
:
"HttpErrorResponse"
ok
:
false
status
:
404
statusText
:
"Not Found"
url
:
"https://azeu1.pp.com:4200/api/Designer/selection/AA%20BB%20CC%2FDD%20EE"
[[Prototype]]
:
_S
</code>
<code>polyfills.4cb30b968c6ea108.js:1
GET https://azeu1.pp.com:4200/api/Designer/selection/AA%20BB%20CC%2FDD%20EE 404 (Not Found)
main.11182255502544c4.js:1
ERROR
wr {headers: lo, status: 404, statusText: 'Not Found', url: 'https://azeu1.pp.com:4200/api/Designer/selection/AA%20BB%20CC%2FDD%20EE', ok: false, …}
error
:
null
headers
:
lo
lazyInit
:
()=> {…}
lazyUpdate
:
null
normalizedNames
:
Map(0) {size: 0}
[[Prototype]]
:
Object
message
:
"Http failure response for https://azeu1.pp.com:4200/api/Designer/selection/AA%20BB%20CC%2FDD%20EE: 404 Not Found"
name
:
"HttpErrorResponse"
ok
:
false
status
:
404
statusText
:
"Not Found"
url
:
"https://azeu1.pp.com:4200/api/Designer/selection/AA%20BB%20CC%2FDD%20EE"
[[Prototype]]
:
_S
</code>
polyfills.4cb30b968c6ea108.js:1
GET https://azeu1.pp.com:4200/api/Designer/selection/AA%20BB%20CC%2FDD%20EE 404 (Not Found)
main.11182255502544c4.js:1
ERROR
wr {headers: lo, status: 404, statusText: 'Not Found', url: 'https://azeu1.pp.com:4200/api/Designer/selection/AA%20BB%20CC%2FDD%20EE', ok: false, …}
error
:
null
headers
:
lo
lazyInit
:
()=> {…}
lazyUpdate
:
null
normalizedNames
:
Map(0) {size: 0}
[[Prototype]]
:
Object
message
:
"Http failure response for https://azeu1.pp.com:4200/api/Designer/selection/AA%20BB%20CC%2FDD%20EE: 404 Not Found"
name
:
"HttpErrorResponse"
ok
:
false
status
:
404
statusText
:
"Not Found"
url
:
"https://azeu1.pp.com:4200/api/Designer/selection/AA%20BB%20CC%2FDD%20EE"
[[Prototype]]
:
_S
The Nginx config is:
<code>worker_processes 1;
events {
worker_connections 1024;
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
server {
listen 80;
server_name azeu1.pp.com;
location / {
root /usr/share/nginx/html;
index index.html index.htm;
try_files $uri $uri/ /index.html;
}
location /api/ {
proxy_pass http://pp_v3:5000/api/;
}
listen 443 ssl;
server_name azeu1.pp.com;
ssl_certificate /etc/nginx/certs/server.crt;
ssl_certificate_key /etc/nginx/certs/server.key;
ssl_protocols TLSv1.2 TLSv1.3;
ssl_ciphers HIGH:!aNULL:!MD5;
error_page 404 /404.html;
location = /404.html {
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
}
}
}
</code>
<code>worker_processes 1;
events {
worker_connections 1024;
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
server {
listen 80;
server_name azeu1.pp.com;
location / {
root /usr/share/nginx/html;
index index.html index.htm;
try_files $uri $uri/ /index.html;
}
location /api/ {
proxy_pass http://pp_v3:5000/api/;
}
listen 443 ssl;
server_name azeu1.pp.com;
ssl_certificate /etc/nginx/certs/server.crt;
ssl_certificate_key /etc/nginx/certs/server.key;
ssl_protocols TLSv1.2 TLSv1.3;
ssl_ciphers HIGH:!aNULL:!MD5;
error_page 404 /404.html;
location = /404.html {
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
}
}
}
</code>
worker_processes 1;
events {
worker_connections 1024;
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
server {
listen 80;
server_name azeu1.pp.com;
location / {
root /usr/share/nginx/html;
index index.html index.htm;
try_files $uri $uri/ /index.html;
}
location /api/ {
proxy_pass http://pp_v3:5000/api/;
}
listen 443 ssl;
server_name azeu1.pp.com;
ssl_certificate /etc/nginx/certs/server.crt;
ssl_certificate_key /etc/nginx/certs/server.key;
ssl_protocols TLSv1.2 TLSv1.3;
ssl_ciphers HIGH:!aNULL:!MD5;
error_page 404 /404.html;
location = /404.html {
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
}
}
}
But for the same endpoint running locally http://localhost:4200/api/Designer/selection/AA%20BB%20CC%2FDD%20EE
, it works. And most of the features in the app work on the server, just this certain one does not.
Could someone tell me what is the potential cause?