Skip to content

Commit

Permalink
DIGG-512: Removing middlehand request for redirecting
Browse files Browse the repository at this point in the history
  • Loading branch information
MikaMunterud committed Jan 7, 2025
1 parent a4d5942 commit e050720
Show file tree
Hide file tree
Showing 15 changed files with 86 additions and 190 deletions.
28 changes: 0 additions & 28 deletions pages/api/entrystore-redirect.ts

This file was deleted.

13 changes: 6 additions & 7 deletions pages/concepts/[concept]/[param].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { useContext, useEffect, useState } from "react";
import { ConceptPage } from "@/features/entryscape/concept-page";
import { EntrystoreProvider } from "@/providers/entrystore-provider";
import { SettingsContext } from "@/providers/settings-provider";
import { getEntryStoreProps } from "@/utilities/entrystore/get-entrystore-props";
import { handleEntryStoreRedirect } from "@/utilities/entrystore/entrystore-redirect";

export default function Concept() {
const { env } = useContext(SettingsContext);
Expand All @@ -17,19 +17,18 @@ export default function Concept() {
if (!concept || !param) return;
const isSandbox = window.location.host.includes("sandbox");

const data = await getEntryStoreProps({
config: {
const data = await handleEntryStoreRedirect(
{
pathPrefix: "/concepts",
redirectPath: "/concepts",
entrystorePathKey: "ENTRYSCAPE_TERMS_PATH",
param: concept,
secondParam: param as string,
},
locale: router.locale || "sv",
isSandbox,
router,
includeBasePath: false,
});
router.locale || "sv",
isSandbox,
);

if (data?.resourceUri) {
setResourceUri(data.resourceUri);
Expand Down
13 changes: 6 additions & 7 deletions pages/concepts/[concept]/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { useContext, useEffect, useState } from "react";
import { ConceptPage } from "@/features/entryscape/concept-page";
import { EntrystoreProvider } from "@/providers/entrystore-provider";
import { SettingsContext } from "@/providers/settings-provider";
import { getEntryStoreProps } from "@/utilities/entrystore/get-entrystore-props";
import { handleEntryStoreRedirect } from "@/utilities/entrystore/entrystore-redirect";

export default function Concept() {
const { env } = useContext(SettingsContext);
Expand All @@ -18,18 +18,17 @@ export default function Concept() {
if (!concept) return;
const isSandbox = window.location.host.includes("sandbox");

const data = await getEntryStoreProps({
config: {
const data = await handleEntryStoreRedirect(
{
pathPrefix: "/concepts",
redirectPath: "/concepts",
entrystorePathKey: "ENTRYSCAPE_TERMS_PATH",
param: concept,
},
locale: router.locale || "sv",
isSandbox,
router,
includeBasePath: false,
});
router.locale || "sv",
isSandbox,
);

if (data?.resourceUri) {
setResourceUri(data.resourceUri);
Expand Down
13 changes: 6 additions & 7 deletions pages/externalconcept/[...concept].tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { useRouter } from "next/router";
import { useEffect } from "react";

import { getEntryStoreProps } from "@/utilities/entrystore/get-entrystore-props";
import { handleEntryStoreRedirect } from "@/utilities/entrystore/entrystore-redirect";

export default function Concept() {
const router = useRouter();
Expand All @@ -12,18 +12,17 @@ export default function Concept() {
if (!concept) return;
const isSandbox = window.location.host.includes("sandbox");

await getEntryStoreProps({
config: {
await handleEntryStoreRedirect(
{
pathPrefix: "/concepts",
redirectPath: "/concepts",
entrystorePathKey: "ENTRYSCAPE_TERMS_PATH",
param: concept,
},
locale: router.locale || "sv",
isSandbox,
router,
includeBasePath: false,
});
router.locale || "sv",
isSandbox,
);
};

fetchEntryStoreProps();
Expand Down
15 changes: 7 additions & 8 deletions pages/externalconcept/index.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { useRouter } from "next/router";
import { useEffect } from "react";

import { getEntryStoreProps } from "@/utilities/entrystore/get-entrystore-props";
import { handleEntryStoreRedirect } from "@/utilities/entrystore/entrystore-redirect";

export default function Concept() {
const router = useRouter();
Expand All @@ -12,18 +12,17 @@ export default function Concept() {
if (!resource) return;
const isSandbox = window.location.host.includes("sandbox");

await getEntryStoreProps({
config: {
await handleEntryStoreRedirect(
{
pathPrefix: "/concepts",
redirectPath: "/concepts",
entrystorePathKey: "ENTRYSCAPE_TERMS_PATH",
},
locale: router.locale || "sv",
isSandbox,
router,
resourceUri: resource as string,
includeBasePath: false,
});
router.locale || "sv",
isSandbox,
resource as string,
);
};

fetchEntryStoreProps();
Expand Down
13 changes: 6 additions & 7 deletions pages/externalspecification/[...specification].tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { useRouter } from "next/router";
import { useEffect } from "react";

import { getEntryStoreProps } from "@/utilities/entrystore/get-entrystore-props";
import { handleEntryStoreRedirect } from "@/utilities/entrystore/entrystore-redirect";

export default function Specification() {
const router = useRouter();
Expand All @@ -12,18 +12,17 @@ export default function Specification() {
if (!specification) return;
const isSandbox = window.location.host.includes("sandbox");

await getEntryStoreProps({
config: {
await handleEntryStoreRedirect(
{
pathPrefix: "/concepts",
redirectPath: "/concepts",
entrystorePathKey: "ENTRYSCAPE_SPECS_PATH",
param: specification,
},
locale: router.locale || "sv",
isSandbox,
router,
includeBasePath: false,
});
router.locale || "sv",
isSandbox,
);
};

fetchEntryStoreProps();
Expand Down
15 changes: 7 additions & 8 deletions pages/externalspecification/index.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { useRouter } from "next/router";
import { useEffect } from "react";

import { getEntryStoreProps } from "@/utilities/entrystore/get-entrystore-props";
import { handleEntryStoreRedirect } from "@/utilities/entrystore/entrystore-redirect";

export default function Specification() {
const router = useRouter();
Expand All @@ -12,18 +12,17 @@ export default function Specification() {
if (!resource) return;
const isSandbox = window.location.host.includes("sandbox");

await getEntryStoreProps({
config: {
await handleEntryStoreRedirect(
{
pathPrefix: "/specifications",
redirectPath: "/specifications",
entrystorePathKey: "ENTRYSCAPE_SPECS_PATH",
},
locale: router.locale || "sv",
isSandbox,
router,
resourceUri: resource as string,
includeBasePath: false,
});
router.locale || "sv",
isSandbox,
resource as string,
);
};

fetchEntryStoreProps();
Expand Down
13 changes: 6 additions & 7 deletions pages/externalterminology/[...terminology].tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { useRouter } from "next/router";
import { useEffect } from "react";

import { getEntryStoreProps } from "@/utilities/entrystore/get-entrystore-props";
import { handleEntryStoreRedirect } from "@/utilities/entrystore/entrystore-redirect";

export default function Terminology() {
const router = useRouter();
Expand All @@ -12,18 +12,17 @@ export default function Terminology() {
if (!terminology) return;
const isSandbox = window.location.host.includes("sandbox");

await getEntryStoreProps({
config: {
await handleEntryStoreRedirect(
{
pathPrefix: "/concepts",
redirectPath: "/terminology",
entrystorePathKey: "ENTRYSCAPE_TERMS_PATH",
param: terminology,
},
locale: router.locale || "sv",
isSandbox,
router,
includeBasePath: false,
});
router.locale || "sv",
isSandbox,
);
};

fetchEntryStoreProps();
Expand Down
15 changes: 7 additions & 8 deletions pages/externalterminology/index.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { useRouter } from "next/router";
import { useEffect } from "react";

import { getEntryStoreProps } from "@/utilities/entrystore/get-entrystore-props";
import { handleEntryStoreRedirect } from "@/utilities/entrystore/entrystore-redirect";

export default function Terminology() {
const router = useRouter();
Expand All @@ -12,18 +12,17 @@ export default function Terminology() {
if (!resource) return;
const isSandbox = window.location.host.includes("sandbox");

await getEntryStoreProps({
config: {
await handleEntryStoreRedirect(
{
pathPrefix: "/concepts",
redirectPath: "/terminology",
entrystorePathKey: "ENTRYSCAPE_TERMS_PATH",
},
locale: router.locale || "sv",
isSandbox,
router,
resourceUri: resource as string,
includeBasePath: false,
});
router.locale || "sv",
isSandbox,
resource as string,
);
};

fetchEntryStoreProps();
Expand Down
13 changes: 6 additions & 7 deletions pages/specifications/[spec]/[param].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { useContext, useEffect, useState } from "react";
import { SpecificationPage } from "@/features/entryscape/specification-page";
import { EntrystoreProvider } from "@/providers/entrystore-provider";
import { SettingsContext } from "@/providers/settings-provider";
import { getEntryStoreProps } from "@/utilities/entrystore/get-entrystore-props";
import { handleEntryStoreRedirect } from "@/utilities/entrystore/entrystore-redirect";

export default function Specification() {
const { env } = useContext(SettingsContext);
Expand All @@ -17,19 +17,18 @@ export default function Specification() {
if (!spec || !param) return;
const isSandbox = window.location.host.includes("sandbox");

const data = await getEntryStoreProps({
config: {
const data = await handleEntryStoreRedirect(
{
pathPrefix: "/specifications",
redirectPath: "/specifications",
entrystorePathKey: "ENTRYSCAPE_SPECS_PATH",
param: spec,
secondParam: param as string,
},
locale: router.locale || "sv",
isSandbox,
router,
includeBasePath: false,
});
router.locale || "sv",
isSandbox,
);

if (data?.resourceUri) {
setResourceUri(data.resourceUri);
Expand Down
13 changes: 6 additions & 7 deletions pages/specifications/[spec]/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { useContext, useEffect, useState } from "react";
import { SpecificationPage } from "@/features/entryscape/specification-page";
import { EntrystoreProvider } from "@/providers/entrystore-provider";
import { SettingsContext } from "@/providers/settings-provider";
import { getEntryStoreProps } from "@/utilities/entrystore/get-entrystore-props";
import { handleEntryStoreRedirect } from "@/utilities/entrystore/entrystore-redirect";

export default function Specification() {
const { env } = useContext(SettingsContext);
Expand All @@ -18,18 +18,17 @@ export default function Specification() {
if (!spec) return;
const isSandbox = window.location.host.includes("sandbox");

const data = await getEntryStoreProps({
config: {
const data = await handleEntryStoreRedirect(
{
pathPrefix: "/specifications",
redirectPath: "/specifications",
entrystorePathKey: "ENTRYSCAPE_SPECS_PATH",
param: spec,
},
locale: router.locale || "sv",
isSandbox,
router,
includeBasePath: false,
});
router.locale || "sv",
isSandbox,
);

if (data?.resourceUri) {
setResourceUri(data.resourceUri);
Expand Down
13 changes: 6 additions & 7 deletions pages/terminology/[term]/[param].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { useContext, useEffect, useState } from "react";
import { ConceptPage } from "@/features/entryscape/concept-page";
import { EntrystoreProvider } from "@/providers/entrystore-provider";
import { SettingsContext } from "@/providers/settings-provider";
import { getEntryStoreProps } from "@/utilities/entrystore/get-entrystore-props";
import { handleEntryStoreRedirect } from "@/utilities/entrystore/entrystore-redirect";

export default function Terminology() {
const { env } = useContext(SettingsContext);
Expand All @@ -17,19 +17,18 @@ export default function Terminology() {
if (!term || !param) return;
const isSandbox = window.location.host.includes("sandbox");

const data = await getEntryStoreProps({
config: {
const data = await handleEntryStoreRedirect(
{
pathPrefix: "/concepts",
redirectPath: "/terminology",
entrystorePathKey: "ENTRYSCAPE_TERMS_PATH",
param: term,
secondParam: param as string,
},
locale: router.locale || "sv",
isSandbox,
router,
includeBasePath: false,
});
router.locale || "sv",
isSandbox,
);

if (data?.resourceUri) {
setResourceUri(data.resourceUri);
Expand Down
Loading

0 comments on commit e050720

Please sign in to comment.