Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
},
"dependencies": {
"@headlessui/react": "^2.2.9",
"@next/third-parties": "^16.1.1",
"@radix-ui/react-alert-dialog": "^1.1.15",
"@radix-ui/react-dialog": "^1.1.15",
"@radix-ui/react-popover": "^1.1.15",
Expand Down
20 changes: 20 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion src/app/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import KakaoProvider from '@/global/context/KakaoProvider';
import QueryProvider from '@/global/context/QueryProvider';
import { GoogleTagManager } from '@next/third-parties/google';
import type { Metadata } from 'next';
import localFont from 'next/font/local';
import './globals.css';
Expand Down Expand Up @@ -86,7 +87,7 @@ export default function RootLayout({
m.mazeUniversalSnippetApiKey = e;
})(window, document, 'https://snippet.maze.co/maze-universal-loader.js', '65a6039c-2384-4c2d-a8e1-546a4f859a08');`}
</Script> */}

<GoogleTagManager gtmId='GTM-PH2N3NWM' />
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

security-high high

하드코딩된 GTM ID는 보안 및 유지보수 측면에서 좋지 않습니다. 환경 변수를 사용하여 관리하는 것이 좋습니다.

Next.js에서는 .env.local 파일에 환경 변수를 저장하고, NEXT_PUBLIC_ 접두사를 사용하여 브라우저에 노출시킬 수 있습니다.

예를 들어, .env.local 파일에 다음과 같이 추가합니다:

NEXT_PUBLIC_GTM_ID=GTM-PH2N3NWM

그리고 코드에서는 process.env.NEXT_PUBLIC_GTM_ID로 접근할 수 있습니다. 이렇게 하면 개발, 스테이징, 프로덕션 환경마다 다른 GTM ID를 쉽게 적용할 수 있고, 민감한 정보가 코드에 직접 노출되는 것을 방지할 수 있습니다. GTM ID가 없는 환경에서는 스크립트가 렌더링되지 않도록 조건부 렌더링을 사용하는 것이 좋습니다.

Suggested change
<GoogleTagManager gtmId='GTM-PH2N3NWM' />
{process.env.NEXT_PUBLIC_GTM_ID && <GoogleTagManager gtmId={process.env.NEXT_PUBLIC_GTM_ID} />}

<body
className={`${pretendard.className} min-h-screen w-full antialiased`}
>
Expand Down
Loading