From ed0eb9c8e2d3060391eaa26499a5bceb08ba8814 Mon Sep 17 00:00:00 2001 From: Fernando Lucchesi Date: Tue, 17 Oct 2023 19:43:09 +0200 Subject: [PATCH 1/3] =?UTF-8?q?=E2=9C=A8=20Improve=20errors=20and=20remove?= =?UTF-8?q?=20trailing=20slash=20/=20#1935?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sanityv3/resolveProductionUrl.js | 2 +- sanityv3/schemas/components/VideoSelector.tsx | 14 +++++++++----- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/sanityv3/resolveProductionUrl.js b/sanityv3/resolveProductionUrl.js index c803e33c5..fc389b760 100644 --- a/sanityv3/resolveProductionUrl.js +++ b/sanityv3/resolveProductionUrl.js @@ -9,7 +9,7 @@ const remoteUrl = () => { const env = window.location.hostname.includes('equinor-web-sites-preprod') ? 'preprod' : 'prod' switch (dataset) { case 'global': - return `https://web-equinor-web-sites-${env}.c2.radix.equinor.com/` + return `https://web-equinor-web-sites-${env}.c2.radix.equinor.com` case 'global-development': return 'https://web-global-development-equinor-web-sites-dev.c2.radix.equinor.com' case 'global-test': diff --git a/sanityv3/schemas/components/VideoSelector.tsx b/sanityv3/schemas/components/VideoSelector.tsx index 7daed95a8..cf7ebce7b 100644 --- a/sanityv3/schemas/components/VideoSelector.tsx +++ b/sanityv3/schemas/components/VideoSelector.tsx @@ -64,11 +64,15 @@ const VideoSelector = forwardRef(function VideoSelector( headers: { Authorization: `Basic ${SCREEN9_AUTH}`, }, - }).then((res) => - res.status !== 200 - ? setError(`Could not retrieve url from Screen9. Please report the error to the dev team.`) - : res.json(), - ) + }) + .then((res) => + res.status !== 200 + ? setError('Could not retrieve url from Screen9. Please report the error to the dev team.') + : res.json(), + ) + .catch((error) => { + setError(`Could not retrieve url from Screen9. Please report the error to the dev team. Error: ${error}`) + }) if (!data.error) { const video = { From f837aeee1a5c147256933c3ba0c7a6d147399eef Mon Sep 17 00:00:00 2001 From: Fernando Lucchesi Date: Thu, 19 Oct 2023 11:46:34 +0200 Subject: [PATCH 2/3] =?UTF-8?q?=F0=9F=90=9B=20Fix=20bug=20on=20GROQ=20quer?= =?UTF-8?q?y?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- search/IndexSanityContent/magazine/sanity.ts | 4 ++-- search/IndexSanityContent/topic/sanity.ts | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/search/IndexSanityContent/magazine/sanity.ts b/search/IndexSanityContent/magazine/sanity.ts index 9c078d3a3..8ae03f927 100644 --- a/search/IndexSanityContent/magazine/sanity.ts +++ b/search/IndexSanityContent/magazine/sanity.ts @@ -28,10 +28,10 @@ export const query = /* groq */ `*[_type == "magazine" && _lang == $lang && !(_i "textBlocks": content[_type == "textBlock"]{ "_key": _key, "title": select( - "isBigText" == true => { + isBigText == true => pt::text(bigTitle), pt::text(title) - }), + ), "ingress": pt::text(ingress), "text": pt::text(text) // TODO: Do this manually to cover all cases }, diff --git a/search/IndexSanityContent/topic/sanity.ts b/search/IndexSanityContent/topic/sanity.ts index 8280a0e80..a55a88d56 100644 --- a/search/IndexSanityContent/topic/sanity.ts +++ b/search/IndexSanityContent/topic/sanity.ts @@ -12,10 +12,10 @@ export const query = /* groq */ `*[_type match "route_" + $lang + "*" && content "textBlocks": content->content[_type == "textBlock"]{ "_key": _key, "title": select( - "isBigText" == true => { + isBigText == true => pt::text(bigTitle), pt::text(title) - }), + ), "ingress": pt::text(ingress), "text": pt::text(text) // TODO: Do this manually to cover all cases }, From f1088cf8eff16602548c7c8a5373e424e0a7aaf4 Mon Sep 17 00:00:00 2001 From: Fernando Lucchesi Date: Fri, 20 Oct 2023 13:52:00 +0200 Subject: [PATCH 3/3] =?UTF-8?q?=E2=9A=97=EF=B8=8F=20Explicity=20set=20cach?= =?UTF-8?q?e=20policy=20for=20SSR=20pages=20#1944?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- web/pages/magasin/index.global.tsx | 4 +++- web/pages/magazine/index.global.tsx | 4 +++- web/pages/news/index.global.tsx | 6 ++++-- web/pages/nyheter/index.global.tsx | 5 ++++- 4 files changed, 14 insertions(+), 5 deletions(-) diff --git a/web/pages/magasin/index.global.tsx b/web/pages/magasin/index.global.tsx index 9b69e1c03..905119b3b 100644 --- a/web/pages/magasin/index.global.tsx +++ b/web/pages/magasin/index.global.tsx @@ -71,12 +71,14 @@ MagazineIndexNorwegian.getLayout = (page: AppProps) => { ) } -export const getServerSideProps: GetServerSideProps = async ({ req, preview = false, locale = 'no' }) => { +export const getServerSideProps: GetServerSideProps = async ({ res, req, preview = false, locale = 'no' }) => { // For the time being, let's just give 404 for satellites // We will also return 404 if the locale is not Norwegian. // This is a hack and and we should improve this at some point // See https://github.com/vercel/next.js/discussions/18485 + res.setHeader('Cache-Control', 'private, no-cache, no-store, max-age=0, must-revalidate') + if (locale !== 'no') { return { notFound: true, diff --git a/web/pages/magazine/index.global.tsx b/web/pages/magazine/index.global.tsx index 2c66fd642..305189f83 100644 --- a/web/pages/magazine/index.global.tsx +++ b/web/pages/magazine/index.global.tsx @@ -66,12 +66,14 @@ MagazineIndex.getLayout = (page: AppProps) => { ) } -export const getServerSideProps: GetServerSideProps = async ({ req, preview = false, locale = 'en' }) => { +export const getServerSideProps: GetServerSideProps = async ({ res, req, preview = false, locale = 'en' }) => { // For the time being, let's just give 404 for satellites // We will also return 404 if the locale is not English. // This is a hack and and we should improve this at some point // See https://github.com/vercel/next.js/discussions/18485 + res.setHeader('Cache-Control', 'private, no-cache, no-store, max-age=0, must-revalidate') + if (locale !== 'en') { return { notFound: true, diff --git a/web/pages/news/index.global.tsx b/web/pages/news/index.global.tsx index 3adfe8719..472dd19a1 100644 --- a/web/pages/news/index.global.tsx +++ b/web/pages/news/index.global.tsx @@ -1,4 +1,4 @@ -import { GetServerSideProps } from 'next' +import { GetServerSideProps, GetStaticPaths } from 'next' import { InstantSearchSSRProvider } from 'react-instantsearch-hooks-web' import { getServerState } from 'react-instantsearch-hooks-server' import type { AppProps } from 'next/app' @@ -67,12 +67,14 @@ NewsRoom.getLayout = (page: AppProps) => { ) } -export const getServerSideProps: GetServerSideProps = async ({ req, preview = false, locale = 'en' }) => { +export const getServerSideProps: GetServerSideProps = async ({ res, req, preview = false, locale = 'en' }) => { // For the time being, let's just give 404 for satellites // We will also return 404 if the locale is not English. // This is a hack and and we should improve this at some point // See https://github.com/vercel/next.js/discussions/18485 + res.setHeader('Cache-Control', 'private, no-cache, no-store, max-age=0, must-revalidate') + if (locale !== 'en') { return { notFound: true, diff --git a/web/pages/nyheter/index.global.tsx b/web/pages/nyheter/index.global.tsx index 24fc2d633..44ad4a074 100644 --- a/web/pages/nyheter/index.global.tsx +++ b/web/pages/nyheter/index.global.tsx @@ -65,11 +65,14 @@ NorwegianNewsRoom.getLayout = (page: AppProps) => { ) } -export const getServerSideProps: GetServerSideProps = async ({ req, preview = false, locale = 'no' }) => { +export const getServerSideProps: GetServerSideProps = async ({ res, req, preview = false, locale = 'no' }) => { // For the time being, let's just give 404 for satellites // We will also return 404 if the locale is not Norwegian. // This is a hack, and we should improve this at some point // See https://github.com/vercel/next.js/discussions/18485 + + res.setHeader('Cache-Control', 'private, no-cache, no-store, max-age=0, must-revalidate') + if (locale !== 'no') { return { notFound: true,