From 236a38212ee10953865096a1bb1c64a5e1dc1794 Mon Sep 17 00:00:00 2001 From: Pooria Setayesh Date: Tue, 10 Dec 2024 20:08:51 +0330 Subject: [PATCH] fix: resolve .env problems --- .env.sample | 1 - src/@types/global.d.ts | 1 - .../products/[...params]/components/ProductGallery.tsx | 7 +++---- src/app/[locale]/(main)/profile/loading.tsx | 7 ++++++- src/app/[locale]/(main)/promotion-center/layout.tsx | 2 +- src/app/[locale]/(main)/promotion-center/loading.tsx | 1 - src/components/Header/components/BottomSection.tsx | 4 ++-- src/config/app.ts | 1 + src/graphql/clients/clientSideMakeClient.ts | 3 ++- src/graphql/clients/serverSideClient.ts | 3 ++- src/middleware.ts | 4 ++-- 11 files changed, 19 insertions(+), 15 deletions(-) diff --git a/.env.sample b/.env.sample index 3ed4e5a..d5b1c8f 100644 --- a/.env.sample +++ b/.env.sample @@ -1,3 +1,2 @@ NEXT_PUBLIC_BACKEND_URL=https://api.nextwoo.ir/graphql -NEXT_PUBLIC_GATEWAY_URL=/backend NEXTAUTH_SECRET=jg3I65KxxWvmLWwbI8Zp9DbJsgyVJ+vHRAARmhF68+A= \ No newline at end of file diff --git a/src/@types/global.d.ts b/src/@types/global.d.ts index 7377cb0..e6c610a 100644 --- a/src/@types/global.d.ts +++ b/src/@types/global.d.ts @@ -8,7 +8,6 @@ declare global { namespace NodeJS { interface ProcessEnv { NEXT_PUBLIC_BACKEND_URL: string; - NEXT_PUBLIC_GATEWAY_URL: string; } } diff --git a/src/app/[locale]/(main)/(container)/products/[...params]/components/ProductGallery.tsx b/src/app/[locale]/(main)/(container)/products/[...params]/components/ProductGallery.tsx index cdeb77a..962ec3c 100644 --- a/src/app/[locale]/(main)/(container)/products/[...params]/components/ProductGallery.tsx +++ b/src/app/[locale]/(main)/(container)/products/[...params]/components/ProductGallery.tsx @@ -1,14 +1,13 @@ 'use client'; -import Image from '@/components/common/Image'; +import { useAppContext } from '@/hooks/useAppContext'; +import { ExpandLess, ExpandMore } from '@mui/icons-material'; import { Box, IconButton, Stack, useTheme } from '@mui/material'; import { FC, useCallback, useRef, useState } from 'react'; +import { Navigation, Pagination } from 'swiper/modules'; import { Swiper, SwiperSlide } from 'swiper/react'; import { Product } from '../../types/common'; import GalleryItem from './GalleryItem'; -import { ExpandLess, ExpandMore } from '@mui/icons-material'; -import { useAppContext } from '@/hooks/useAppContext'; -import { Navigation, Pagination } from 'swiper/modules'; export type GalleryImages = Extract< Product['galleryImages'], diff --git a/src/app/[locale]/(main)/profile/loading.tsx b/src/app/[locale]/(main)/profile/loading.tsx index c5875c5..8a1c954 100644 --- a/src/app/[locale]/(main)/profile/loading.tsx +++ b/src/app/[locale]/(main)/profile/loading.tsx @@ -2,7 +2,12 @@ import { CircularProgress, Stack } from '@mui/material'; const loading = () => { return ( - + ); diff --git a/src/app/[locale]/(main)/promotion-center/layout.tsx b/src/app/[locale]/(main)/promotion-center/layout.tsx index 65f3833..013bff8 100644 --- a/src/app/[locale]/(main)/promotion-center/layout.tsx +++ b/src/app/[locale]/(main)/promotion-center/layout.tsx @@ -1,6 +1,6 @@ import { Card, CardContent, Container } from '@mui/material'; -import Header from './components/Header'; import { FC, ReactNode } from 'react'; +import Header from './components/Header'; interface LayoutProps { children: ReactNode; diff --git a/src/app/[locale]/(main)/promotion-center/loading.tsx b/src/app/[locale]/(main)/promotion-center/loading.tsx index 68f52d0..1f4e9ec 100644 --- a/src/app/[locale]/(main)/promotion-center/loading.tsx +++ b/src/app/[locale]/(main)/promotion-center/loading.tsx @@ -1,6 +1,5 @@ import { VariableProductItemSkeleton } from '@/components/VariableProductItem'; import { Grid } from '@mui/material'; -import React from 'react'; const loading = () => { return ( diff --git a/src/components/Header/components/BottomSection.tsx b/src/components/Header/components/BottomSection.tsx index 9851b1c..3619a0a 100644 --- a/src/components/Header/components/BottomSection.tsx +++ b/src/components/Header/components/BottomSection.tsx @@ -1,8 +1,8 @@ +import { Link as NextLink } from '@/navigation'; +import { bestSellingSortOption } from '@/static/sortOptions'; import Box from '@mui/material/Box'; import Button from '@mui/material/Button'; import { useTranslations } from 'next-intl'; -import { Link as NextLink } from '@/navigation'; -import { bestSellingSortOption } from '@/static/sortOptions'; const BottomSection = () => { const t = useTranslations(); diff --git a/src/config/app.ts b/src/config/app.ts index b510003..95b63c0 100644 --- a/src/config/app.ts +++ b/src/config/app.ts @@ -1 +1,2 @@ export const protectedRoutes = ['/profile']; +export const PUBLIC_GATEWAY_URL = '/backend'; diff --git a/src/graphql/clients/clientSideMakeClient.ts b/src/graphql/clients/clientSideMakeClient.ts index 577cba6..e4bf1ff 100644 --- a/src/graphql/clients/clientSideMakeClient.ts +++ b/src/graphql/clients/clientSideMakeClient.ts @@ -5,9 +5,10 @@ import { SSRMultipartLink, } from '@apollo/experimental-nextjs-app-support/ssr'; import { createErrorLink } from '../utils'; +import { PUBLIC_GATEWAY_URL } from '@/config/app'; const httpLink = new HttpLink({ - uri: process.env.NEXT_PUBLIC_GATEWAY_URL, + uri: PUBLIC_GATEWAY_URL, }); export const makeClient = () => { diff --git a/src/graphql/clients/serverSideClient.ts b/src/graphql/clients/serverSideClient.ts index 73ad610..f498acc 100644 --- a/src/graphql/clients/serverSideClient.ts +++ b/src/graphql/clients/serverSideClient.ts @@ -1,3 +1,4 @@ +import { PUBLIC_GATEWAY_URL } from '@/config/app'; import { ApolloClient, HttpLink, InMemoryCache, from } from '@apollo/client'; import { registerApolloClient } from '@apollo/experimental-nextjs-app-support/rsc'; import { cookies } from 'next/headers'; @@ -6,7 +7,7 @@ export const { getClient } = registerApolloClient(() => { const cookiesStore = cookies(); const httpLink = new HttpLink({ - uri: `${process.env.__NEXT_PRIVATE_ORIGIN}${process.env.NEXT_PUBLIC_GATEWAY_URL}`, + uri: `${process.env.__NEXT_PRIVATE_ORIGIN}${PUBLIC_GATEWAY_URL}`, headers: { cookie: cookiesStore.toString(), }, diff --git a/src/middleware.ts b/src/middleware.ts index 85a03f9..63efc19 100644 --- a/src/middleware.ts +++ b/src/middleware.ts @@ -3,7 +3,7 @@ import { NextRequestWithAuth, withAuth } from 'next-auth/middleware'; import nextIntlMiddleware from 'next-intl/middleware'; import type { NextRequest } from 'next/server'; import { NextResponse } from 'next/server'; -import { protectedRoutes } from './config/app'; +import { PUBLIC_GATEWAY_URL, protectedRoutes } from './config/app'; const intlMiddleware = (request: NextRequest) => Promise.resolve( @@ -19,7 +19,7 @@ async function middleware(request: NextRequestWithAuth) { const { pathname } = request.nextUrl; request.headers.set('x-pathname', pathname); - if (pathname.startsWith(process.env.NEXT_PUBLIC_GATEWAY_URL)) { + if (pathname.startsWith(PUBLIC_GATEWAY_URL)) { const token = request.nextauth.token; if (token?.accessToken) {