From 4e501d114c8f4ba5d90f3e7294630074a5aab8df Mon Sep 17 00:00:00 2001 From: Jordan <74591126+jordansmrd@users.noreply.github.com> Date: Sun, 4 Aug 2024 12:57:18 +0700 Subject: [PATCH] update --- apps/web/.env | 8 ++++---- apps/web/next.config.js | 2 +- apps/web/src/config/config.ts | 8 ++++++++ apps/web/src/utils/action/user.middleware.ts | 4 ++-- 4 files changed, 15 insertions(+), 7 deletions(-) diff --git a/apps/web/.env b/apps/web/.env index 23fc386..4c419eb 100644 --- a/apps/web/.env +++ b/apps/web/.env @@ -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" \ No newline at end of file +NEXT_PUBLIC_GOOGLE_MAPS_ID="86c7b10cc9bfd65e" +COOKIE_DOMAIN="purwadhikabootcamp" \ No newline at end of file diff --git a/apps/web/next.config.js b/apps/web/next.config.js index 593c51d..0fcc68c 100644 --- a/apps/web/next.config.js +++ b/apps/web/next.config.js @@ -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, diff --git a/apps/web/src/config/config.ts b/apps/web/src/config/config.ts index f9fd399..30f0f63 100644 --- a/apps/web/src/config/config.ts +++ b/apps/web/src/config/config.ts @@ -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 = { + sameSite: "strict", + secure: true, + domain: process.env.COOKIE_DOMAIN, +}; diff --git a/apps/web/src/utils/action/user.middleware.ts b/apps/web/src/utils/action/user.middleware.ts index 05f5f1c..8262615 100644 --- a/apps/web/src/utils/action/user.middleware.ts +++ b/apps/web/src/utils/action/user.middleware.ts @@ -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"; @@ -22,7 +22,7 @@ export const getUserSession = async (res: NextResponse, 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) {