Fix cache headers for index html file (#28)

Part of <https://www.notion.so/Gentx-like-attestation-mechanism-to-add-validators-at-genesis-time-19da6b22d47280ecbf1fe657c241ff59>

- Use serve package for controlling separate cache headers for files

Reviewed-on: LaconicNetwork/laconic-wallet-web#28
Co-authored-by: Nabarun <nabarun@deepstacksoft.com>
Co-committed-by: Nabarun <nabarun@deepstacksoft.com>
This commit is contained in:
Nabarun 2025-05-02 08:23:22 +00:00 committed by nabarun
parent b2eafe59b3
commit f47850ebfa
4 changed files with 26 additions and 3 deletions

View File

@ -14,6 +14,7 @@ services:
command: ["bash", "/scripts/run.sh"] command: ["bash", "/scripts/run.sh"]
volumes: volumes:
- ../config/app/run.sh:/scripts/run.sh - ../config/app/run.sh:/scripts/run.sh
- ../config/app/serve.json:/app/serve.json
ports: ports:
- "80" - "80"
healthcheck: healthcheck:

View File

@ -28,5 +28,5 @@ mkdir -p "$(dirname "$FILE_PATH")"
# Write verification code to the file # Write verification code to the file
echo "$WALLET_CONNECT_VERIFY_CODE" > "$FILE_PATH" echo "$WALLET_CONNECT_VERIFY_CODE" > "$FILE_PATH"
# Serve build dir # Serve build dir with explicit config
http-server --proxy http://localhost:80? -p 80 /app/build serve -s -l 80 -c /app/serve.json /app/build

View File

@ -0,0 +1,22 @@
{
"headers": [
{
"source": "/index.html",
"headers": [
{
"key": "Cache-Control",
"value": "no-cache, must-revalidate"
}
]
},
{
"source": "/static/**/*.{js,css,png,jpg,jpeg,gif,svg,ico}",
"headers": [
{
"key": "Cache-Control",
"value": "public, max-age=31536000, immutable"
}
]
}
]
}

View File

@ -33,7 +33,7 @@ RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
RUN mkdir -p /scripts RUN mkdir -p /scripts
# Install simple web server for now (use nginx perhaps later) # Install simple web server for now (use nginx perhaps later)
RUN yarn global add http-server RUN yarn global add serve
WORKDIR /app WORKDIR /app
COPY . . COPY . .