Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
jordansmrd committed Aug 4, 2024
1 parent 6ffdb5c commit 4e501d1
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 7 deletions.
8 changes: 4 additions & 4 deletions apps/web/.env
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
NEXT_PUBLIC_BASE_API_URL="http://localhost:8000"
NEXT_PUBLIC_IMAGES_HOSTNAME="localhost"

NEXT_PUBLIC_BASE_API_URL=https://jcwd270401-api.purwadhikabootcamp.com/
NEXT_PUBLIC_IMAGES_HOSTNAME=jcwd270401-api.purwadhikabootcamp.com
NEXT_PUBLIC_GOOGLE_MAPS_KEY="AIzaSyDMNV0s-HmdxdmZa119tdCiDpygJaeh8IQ"
NEXT_PUBLIC_GOOGLE_MAPS_ID="86c7b10cc9bfd65e"
NEXT_PUBLIC_GOOGLE_MAPS_ID="86c7b10cc9bfd65e"
COOKIE_DOMAIN="purwadhikabootcamp"
2 changes: 1 addition & 1 deletion apps/web/next.config.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/** @type {import('next').NextConfig} */
const nextConfig = {
images: {
remotePatterns: [{ hostname: "th.bing.com" }, { protocol: "http", hostname: process.env.NEXT_PUBLIC_IMAGES_HOSTNAME }],
remotePatterns: [{ hostname: "th.bing.com" }, { protocol: "https", hostname: process.env.NEXT_PUBLIC_IMAGES_HOSTNAME }],
},
experimental: {
missingSuspenseWithCSRBailout: false,
Expand Down
8 changes: 8 additions & 0 deletions apps/web/src/config/config.ts
Original file line number Diff line number Diff line change
@@ -1 +1,9 @@
import { ResponseCookie } from "next/dist/compiled/@edge-runtime/cookies";

export const NEXT_PUBLIC_BASE_API_URL = process.env.NEXT_PUBLIC_BASE_API_URL;

export const cookiesOpt: Partial<ResponseCookie> = {
sameSite: "strict",
secure: true,
domain: process.env.COOKIE_DOMAIN,
};
4 changes: 2 additions & 2 deletions apps/web/src/utils/action/user.middleware.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { NEXT_PUBLIC_BASE_API_URL } from "@/config/config";
import { cookiesOpt, NEXT_PUBLIC_BASE_API_URL } from "@/config/config";
import { TUser } from "@/models/user.model";
import { jwtDecode } from "jwt-decode";
import type { NextResponse } from "next/server";
Expand All @@ -22,7 +22,7 @@ export const getUserSession = async (res: NextResponse<unknown>, refresh_token:
res.cookies.delete("access_token");
return null;
}
res.cookies.set("access_token", data.accessToken);
res.cookies.set("access_token", data.accessToken, cookiesOpt);
const user = jwtDecode(data.accessToken) as TUser;
return user;
} catch (error) {
Expand Down

0 comments on commit 4e501d1

Please sign in to comment.