Skip to content

Commit e37443d

Browse files
committed
fix: envs
1 parent 4d1f5a6 commit e37443d

File tree

8 files changed

+22
-14
lines changed

8 files changed

+22
-14
lines changed

.env.example

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
API_URL=
2-
APP_URL=
2+
NEXT_PUBLIC_APP_URL=
33

44
FIREBASE_API_KEY=
55
FIREBASE_AUTH_DOMAIN=

.github/workflows/prod-deploy.yml

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,15 @@ jobs:
2929
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
3030
aws-region: ${{ secrets.AWS_REGION }}
3131

32-
- name: export secret key
33-
run: |
34-
echo "${{ vars.production_ENV }}" > .env
32+
# - name: export secret key
33+
# run: |
34+
# echo "${{ vars.production_ENV }}" > .env
3535

3636
- name: Login to Amazon ECR
3737
id: login-ecr
3838
uses: aws-actions/amazon-ecr-login@v1
3939
with:
40-
mask-password: 'true'
40+
mask-password: "true"
4141

4242
# This is a separate action that sets up buildx runner
4343
- name: Setup Docker Buildx
@@ -58,8 +58,11 @@ jobs:
5858
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
5959
ECR_REPOSITORY: ${{ secrets.REPOSITORY }}
6060
IMAGE_TAG: ${{ vars.IMAGE_TAG }}
61+
NEXT_PUBLIC_APP_URL: ${{ vars.NEXT_PUBLIC_APP_URL }}
6162
run: |
62-
docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG .
63+
docker build \
64+
--build-arg NEXT_PUBLIC_APP_URL=$NEXT_PUBLIC_APP_URL \
65+
-t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG .
6366
docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG
6467
6568
deploy-frontend-service:

Dockerfile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@ FROM node:24-alpine AS builder
1919
WORKDIR /app
2020
COPY . .
2121

22+
# Accept build arguments for NEXT_PUBLIC environment variables
23+
ARG NEXT_PUBLIC_APP_URL
24+
ENV NEXT_PUBLIC_APP_URL=$NEXT_PUBLIC_APP_URL
25+
2226
RUN yarn
2327

2428
RUN yarn build

app/layout.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ export const viewport: Viewport = {
2525
export const metadata: Metadata = {
2626
title: SITE_NAME,
2727
description: SITE_DESCRIPTION,
28-
metadataBase: new URL(process.env.APP_URL!),
28+
metadataBase: new URL(process.env.NEXT_PUBLIC_APP_URL!),
2929
keywords: [
3030
'library management',
3131
'book tracking',

app/robots.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,6 @@ export default function robots(): MetadataRoute.Robots {
1414
'/users/*',
1515
],
1616
},
17-
sitemap: `${process.env.APP_URL}/sitemap.xml`,
17+
sitemap: `${process.env.NEXT_PUBLIC_APP_URL}/sitemap.xml`,
1818
}
1919
}

lib/actions/login.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,8 @@ export async function loginAction(
5050
cookieStore.set(sessionName, token, {
5151
maxAge,
5252
httpOnly: true,
53-
domain: `.${process.env.APP_URL?.slice(process.env.APP_URL.indexOf('://') + 3)}`,
54-
secure: process.env.NODE_ENV === 'production',
55-
sameSite: 'lax',
53+
secure: true,
54+
sameSite: 'strict',
5655
})
5756

5857
// set active library

lib/api/common.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1-
// utilized next.config.js rewrites
2-
// cookies are available in client requests
3-
export const BASE_URL = `${process.env.APP_URL}/api/v1`
1+
export const BASE_URL =
2+
typeof window === 'undefined'
3+
? `${process.env.API_URL}/api/v1`
4+
: `${process.env.NEXT_PUBLIC_APP_URL}/api/v1`

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
"private": true,
55
"scripts": {
66
"dev": "next dev --turbopack",
7+
"devs": "next dev --turbopack --experimental-https",
78
"build": "next build --turbopack",
89
"start": "next start",
910
"lint": "eslint .",

0 commit comments

Comments
 (0)