Skip to content

Commit

Permalink
fix: resolve .env problems
Browse files Browse the repository at this point in the history
  • Loading branch information
pooriaset committed Dec 10, 2024
1 parent 6f8b431 commit 236a382
Show file tree
Hide file tree
Showing 11 changed files with 19 additions and 15 deletions.
1 change: 0 additions & 1 deletion .env.sample
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
NEXT_PUBLIC_BACKEND_URL=https://api.nextwoo.ir/graphql
NEXT_PUBLIC_GATEWAY_URL=/backend
NEXTAUTH_SECRET=jg3I65KxxWvmLWwbI8Zp9DbJsgyVJ+vHRAARmhF68+A=
1 change: 0 additions & 1 deletion src/@types/global.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ declare global {
namespace NodeJS {
interface ProcessEnv {
NEXT_PUBLIC_BACKEND_URL: string;
NEXT_PUBLIC_GATEWAY_URL: string;
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -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'],
Expand Down
7 changes: 6 additions & 1 deletion src/app/[locale]/(main)/profile/loading.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,12 @@ import { CircularProgress, Stack } from '@mui/material';

const loading = () => {
return (
<Stack alignItems="center" justifyContent="center" height="100%">
<Stack
alignItems="center"
justifyContent="center"
height="100%"
flexGrow={1}
>
<CircularProgress size={24} />
</Stack>
);
Expand Down
2 changes: 1 addition & 1 deletion src/app/[locale]/(main)/promotion-center/layout.tsx
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
1 change: 0 additions & 1 deletion src/app/[locale]/(main)/promotion-center/loading.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { VariableProductItemSkeleton } from '@/components/VariableProductItem';
import { Grid } from '@mui/material';
import React from 'react';

const loading = () => {
return (
Expand Down
4 changes: 2 additions & 2 deletions src/components/Header/components/BottomSection.tsx
Original file line number Diff line number Diff line change
@@ -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();
Expand Down
1 change: 1 addition & 0 deletions src/config/app.ts
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
export const protectedRoutes = ['/profile'];
export const PUBLIC_GATEWAY_URL = '/backend';
3 changes: 2 additions & 1 deletion src/graphql/clients/clientSideMakeClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 = () => {
Expand Down
3 changes: 2 additions & 1 deletion src/graphql/clients/serverSideClient.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -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(),
},
Expand Down
4 changes: 2 additions & 2 deletions src/middleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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) {
Expand Down

0 comments on commit 236a382

Please sign in to comment.