Skip to content

Commit acb014f

Browse files
fix: nginx 404 route
1 parent a34f25f commit acb014f

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

Diff for: Dockerfile

+2
Original file line numberDiff line numberDiff line change
@@ -25,5 +25,7 @@ FROM nginx:1.27.2-alpine AS prod
2525

2626
ARG APP_PATH_DEFAULT
2727

28+
COPY --from=builder ${APP_PATH_DEFAULT}/nginx.conf /etc/nginx/conf.d/default.conf
29+
2830
COPY --from=builder ${APP_PATH_DEFAULT}/build /usr/share/nginx/html/docs
2931
COPY --from=builder ${APP_PATH_DEFAULT}/static/img/favicon.svg /usr/share/nginx/html/docs

Diff for: nginx.conf

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
server {
2+
listen 80;
3+
listen [::]:80;
4+
server_name localhost;
5+
6+
# This location serves index.html as the homepage
7+
location / {
8+
root /usr/share/nginx/html/; # Adjust path if your files are in a different location
9+
index /docs/index.html; # Ensure index.html is set as the default index
10+
try_files $uri $uri/ /docs/index.html; # Fallback to index.html for any unknown path
11+
}
12+
13+
# Handle 404 errors
14+
error_page 404 = /docs/index.html; # Redirect 404 errors to index.html
15+
16+
# Handle server errors
17+
error_page 500 502 503 504 /50x.html;
18+
location = /50x.html {
19+
root /usr/share/nginx/html;
20+
}
21+
}
22+

0 commit comments

Comments
 (0)