diff --git a/.github/workflows/deploy.yaml b/.github/workflows/deploy.yaml index 5aac8aa2..8bfd840a 100644 --- a/.github/workflows/deploy.yaml +++ b/.github/workflows/deploy.yaml @@ -3,7 +3,7 @@ name: Create and publish a Docker image to AWS ECR ans deploy to EC2 on: push: branches: - - main + - bug/BAR-248 env: REGISTRY: ${{ secrets.AWS_ECR_REGISTRY }} diff --git a/middleware.ts b/middleware.ts index 7d1b78d4..104b0f54 100644 --- a/middleware.ts +++ b/middleware.ts @@ -1,14 +1,17 @@ import type { NextRequest } from 'next/server'; import { NextResponse } from 'next/server'; +import { STORAGE_KEY } from '@models/storage'; + export const middleware = async (request: NextRequest) => { - const refreshToken = request.cookies.get('refreshToken'); + const refreshToken = request.cookies.get(STORAGE_KEY.REFRESH_TOKEN); if (request.nextUrl.pathname.startsWith('/terms')) return; - if (refreshToken && request.nextUrl.pathname === '/') { + if (refreshToken?.value && request.nextUrl.pathname === '/') { return NextResponse.redirect(new URL('/main', request.url)); } + if ( !refreshToken && request.nextUrl.pathname !== '/' &&