Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 19 additions & 16 deletions src/components/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -113,22 +113,25 @@ const HeaderLinks: React.FC<{ library: LibraryData }> = ({ library }) => {
{libraryWebsite.title ?? `${libraryName} Home`}
</AnchorButton>
)}
<NavButton
variant="ghost"
color="ui.black"
href="/magazines"
sx={{ mr: 1 }}
>
Magazines (logged in users)
</NavButton>
<NavButton
variant="ghost"
color="ui.black"
href="/magazines-preview"
sx={{ mr: 1 }}
>
Magazines (anonymous users)
</NavButton>
{isAuthenticated ? (
<NavButton
variant="ghost"
color="ui.black"
href="/magazines"
sx={{ mr: 1 }}
>
Magazines
</NavButton>
) : (
<NavButton
variant="ghost"
color="ui.black"
href="/magazines-preview"
sx={{ mr: 1 }}
>
Magazines
</NavButton>
)}
<NavButton
variant="ghost"
color="ui.black"
Expand Down
17 changes: 15 additions & 2 deletions src/config/magazines.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,21 @@ export function getMagazineApiUrl(): string {
* Get the allowed origin for magazine iframe communication
*/
export function getMagazineAllowedOrigin(): string {
const baseUrl = getMagazineReaderUrl();
return process.env.NEXT_PUBLIC_MAGAZINES_ORIGIN || new URL(baseUrl).origin;
const overrideOrigin = process.env.NEXT_PUBLIC_MAGAZINES_ORIGIN;

if (overrideOrigin) {
try {
return new URL(overrideOrigin).origin;
} catch {
// Ignore invalid override and fall back to reader base URL origin.
}
}

try {
return new URL(getMagazineReaderUrl()).origin;
} catch {
return MAGAZINE_READER_URLS.production;
}
}

/**
Expand Down
5 changes: 2 additions & 3 deletions src/pages/[library]/magazines/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import * as React from "react";
import { NextPage, GetStaticProps, GetStaticPaths } from "next";
import LayoutPage from "components/LayoutPage";
import withAppProps, { AppProps } from "dataflow/withAppProps";
// import useUser from "components/context/UserContext";
import useUser from "components/context/UserContext";
import useLogin from "auth/useLogin";
import useLibraryContext from "components/context/LibraryContext";
import {
Expand All @@ -20,8 +20,7 @@ import BreadcrumbBar from "components/BreadcrumbBar";

const MagazinesFixedContent: React.FC = () => {
const iframeRef = React.useRef<HTMLIFrameElement | null>(null);
const token = "MOCK_TOKEN";
// const { token } = useUser();
const { token } = useUser();
const { initLogin } = useLogin();
const { slug } = useLibraryContext();

Expand Down