From aff077104607f7010cc53728ac2c554bb20fed29 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Magnus=20Alexander=20Str=C3=B8mseng?= Date: Wed, 10 Apr 2024 16:09:41 +0200 Subject: [PATCH] tro to fix images and env url --- .github/workflows/autoredeploy.yml | 3 +-- frontend/.env.development | 4 +--- frontend/.env.production | 4 +--- frontend/src/app/blog/[articleSlug]/page.tsx | 6 +++--- frontend/src/app/projects/[projectSlug]/page.tsx | 6 +++--- frontend/src/app/projects/page.tsx | 6 +++--- frontend/src/app/satellites/page.tsx | 6 +++--- .../src/components/RelatedProjectsAndSatellites.tsx | 6 +++--- frontend/src/components/wrappers/ApolloWrapper.tsx | 4 ++-- frontend/src/lib/ApolloClient.js | 4 ++-- frontend/src/lib/data/fetchArticleInfo.tsx | 12 ++++++------ frontend/src/lib/data/fetchMostRecentImage.tsx | 6 +++--- 12 files changed, 31 insertions(+), 36 deletions(-) diff --git a/.github/workflows/autoredeploy.yml b/.github/workflows/autoredeploy.yml index 95654cb..25917f6 100644 --- a/.github/workflows/autoredeploy.yml +++ b/.github/workflows/autoredeploy.yml @@ -24,8 +24,7 @@ jobs: echo "JWT_SECRET=${{ secrets.JWT_SECRET }}" >> .env echo "TRANSFER_TOKEN_SALT=${{ secrets.TRANSFER_TOKEN_SALT }}" >> .env # Create .env.production with HOST_URL Frontend - echo "INTERNAL_STRAPI_URL=${{ vars.INTERNAL_STRAPI_URL }}" >> .env.production - echo "OUTSIDE_STRAPI_URL=${{ vars.OUTSIDE_STRAPI_URL }}" >> .env.production + echo "STRAPI_URL=${{ vars.STRAPI_URL }}" >> .env.production - name: Docker build run: docker-compose build - name: Docker up diff --git a/frontend/.env.development b/frontend/.env.development index 45430ae..6daed48 100644 --- a/frontend/.env.development +++ b/frontend/.env.development @@ -1,4 +1,2 @@ # Database url for outside requests -OUTSIDE_STRAPI_URL=http://localhost:1337 - -INTERNAL_STRAPI_URL=http://localhost:1337 \ No newline at end of file +STRAPI_URL=http://localhost:1337 diff --git a/frontend/.env.production b/frontend/.env.production index 8bdef3f..4b3d365 100644 --- a/frontend/.env.production +++ b/frontend/.env.production @@ -1,5 +1,3 @@ # Database url for outside requests, set in github repo variables -OUTSIDE_STRAPI_URL=http://web.hypso.ies.ntnu.no:1337 +STRAPI_URL=http://web.hypso.ies.ntnu.no:1337 -# Database url for internal requests between the docker containers, set in github repo variables -INTERNAL_STRAPI_URL=http://backend:1337 diff --git a/frontend/src/app/blog/[articleSlug]/page.tsx b/frontend/src/app/blog/[articleSlug]/page.tsx index 14ae711..6682d49 100644 --- a/frontend/src/app/blog/[articleSlug]/page.tsx +++ b/frontend/src/app/blog/[articleSlug]/page.tsx @@ -4,7 +4,7 @@ import { BlocksContent } from "@strapi/blocks-react-renderer"; import BlockRendererClient from "@/components/BlockRendererClient"; import { gql } from "@/__generated__/gql"; import { getClient } from "@/lib/ApolloClient"; -const OUTSIDE_STRAPI_URL = process.env.OUTSIDE_STRAPI_URL; +const STRAPI_URL = process.env.STRAPI_URL; const GET_ARTICLE_BY_SLUG = gql( `query ArticleWithSlug($articlesFilters: ArticleFiltersInput) { @@ -70,8 +70,8 @@ export default async function Page({ graphqlData.data.articles?.data[0]?.attributes?.author?.data?.attributes ?.avatar?.data?.attributes?.url; - if (OUTSIDE_STRAPI_URL && avatarURL != undefined) { - avatarURL = OUTSIDE_STRAPI_URL + avatarURL; + if (STRAPI_URL && avatarURL != undefined) { + avatarURL = STRAPI_URL + avatarURL; } const article = graphqlData.data.articles?.data[0]; diff --git a/frontend/src/app/projects/[projectSlug]/page.tsx b/frontend/src/app/projects/[projectSlug]/page.tsx index 0a7825f..8518853 100644 --- a/frontend/src/app/projects/[projectSlug]/page.tsx +++ b/frontend/src/app/projects/[projectSlug]/page.tsx @@ -4,7 +4,7 @@ import { getClient } from "@/lib/ApolloClient"; import { BlocksContent } from "@strapi/blocks-react-renderer"; import RelatedProjectsAndSatellites from "@/components/RelatedProjectsAndSatellites"; import { ProjectOrSatellite } from "@/app/satellites/[satelliteSlug]/page"; -const OUTSIDE_STRAPI_URL = process.env.OUTSIDE_STRAPI_URL; +const STRAPI_URL = process.env.STRAPI_URL; const GET_PROJECT_BY_SLUG = gql(` query Projects($projectFilters: ProjectFiltersInput) { @@ -69,8 +69,8 @@ export default async function Page({ let projectTitle = projects?.attributes?.slug; - if (OUTSIDE_STRAPI_URL && projectTitle != undefined) { - projectTitle = OUTSIDE_STRAPI_URL + projectTitle; + if (STRAPI_URL && projectTitle != undefined) { + projectTitle = STRAPI_URL + projectTitle; } return (
diff --git a/frontend/src/app/projects/page.tsx b/frontend/src/app/projects/page.tsx index be85fd6..9c5270c 100644 --- a/frontend/src/app/projects/page.tsx +++ b/frontend/src/app/projects/page.tsx @@ -10,7 +10,7 @@ import { PageSubtitle, } from "@/components/PageHeader"; import { OuiImage } from "@/components/fullBlogCard"; -const OUTSIDE_STRAPI_URL = process.env.OUTSIDE_STRAPI_URL; +const STRAPI_URL = process.env.STRAPI_URL; const GET_PROJECTS = gql(` query GET_PROJECTS { @@ -71,8 +71,8 @@ export default async function ProjectsPage() { project?.attributes?.previewImage?.data?.attributes ?.url; - if (OUTSIDE_STRAPI_URL && previewImage != undefined) { - previewImage = OUTSIDE_STRAPI_URL + previewImage; + if (STRAPI_URL && previewImage != undefined) { + previewImage = STRAPI_URL + previewImage; } return ( { return new ApolloClient({ cache: new InMemoryCache(), link: new HttpLink({ // this needs to be an absolute url, as relative urls cannot be used in SSR - uri: INTERNAL_STRAPI_URL + "/graphql", + uri: STRAPI_URL + "/graphql", // you can disable result caching here if you want to // (this does not work if you are rendering your page with `export const dynamic = "force-static"`) fetchOptions: { cache: "no-store" }, diff --git a/frontend/src/lib/data/fetchArticleInfo.tsx b/frontend/src/lib/data/fetchArticleInfo.tsx index d829ac8..4c4f511 100644 --- a/frontend/src/lib/data/fetchArticleInfo.tsx +++ b/frontend/src/lib/data/fetchArticleInfo.tsx @@ -4,7 +4,7 @@ import { BlocksContent } from "@strapi/blocks-react-renderer"; import { Enum_Article_Tag } from "@/__generated__/graphql"; import { BlogPost } from "@/app/blog/page"; -const OUTSIDE_STRAPI_URL = process.env.OUTSIDE_STRAPI_URL; +const STRAPI_URL = process.env.STRAPI_URL; const GET_ARTICLES = gql(` query GET_ARTICLES($pagination: PaginationArg, $filters: ArticleFiltersInput) { @@ -106,8 +106,8 @@ export default async function fetchArticlePages({ article?.attributes?.author?.data?.attributes?.avatar?.data ?.attributes?.url; - if (OUTSIDE_STRAPI_URL && avatarURL != undefined) { - avatarURL = OUTSIDE_STRAPI_URL + avatarURL; + if (STRAPI_URL && avatarURL != undefined) { + avatarURL = STRAPI_URL + avatarURL; } const authorName: string | undefined = @@ -117,8 +117,8 @@ export default async function fetchArticlePages({ const datePublished: any = article?.attributes?.datePublished; let coverImage: string | undefined = article?.attributes?.coverImage?.data?.attributes?.url; - if (OUTSIDE_STRAPI_URL && coverImage != undefined) { - coverImage = OUTSIDE_STRAPI_URL + coverImage; + if (STRAPI_URL && coverImage != undefined) { + coverImage = STRAPI_URL + coverImage; } let content: BlocksContent = article?.attributes?.body ?? []; @@ -139,7 +139,7 @@ export default async function fetchArticlePages({ coverImage, datePublished, tag, - HOST_URL: OUTSIDE_STRAPI_URL, + HOST_URL: STRAPI_URL, authorName, avatarURL, slug: article.attributes.slug, diff --git a/frontend/src/lib/data/fetchMostRecentImage.tsx b/frontend/src/lib/data/fetchMostRecentImage.tsx index f10d9c6..4bc9ef8 100644 --- a/frontend/src/lib/data/fetchMostRecentImage.tsx +++ b/frontend/src/lib/data/fetchMostRecentImage.tsx @@ -2,7 +2,7 @@ import { gql } from "@/__generated__/gql"; import { getClient } from "../ApolloClient"; import Image from "next/image"; -const OUTSIDE_STRAPI_URL = process.env.OUTSIDE_STRAPI_URL; +const STRAPI_URL = process.env.STRAPI_URL; const GET_MOST_RECENT_IMAGE = gql(` query MostRecentImages { @@ -43,8 +43,8 @@ export default async function fetchMostrecentImage() { graphqlData.data.mostRecentImages?.data[0]?.attributes?.mostRecentImage ?.data?.attributes?.url; - if (OUTSIDE_STRAPI_URL && mostRecentImageURL != undefined) { - mostRecentImageURL = OUTSIDE_STRAPI_URL + mostRecentImageURL; + if (STRAPI_URL && mostRecentImageURL != undefined) { + mostRecentImageURL = STRAPI_URL + mostRecentImageURL; } else { mostRecentImageURL = ""; }