Skip to content

A fully open source & end-to-end encrypted note taking alternative to Evernote.

monograph: fix PUBLIC_URL on client * use loader to get PUBLIC_URL

01zulfi54d6a5c30719
diff --git a/apps/monograph/app/components/monograph-chat.tsx b/apps/monograph/app/components/monograph-chat.tsx
index f671d9ad1..5c577609b 100644
--- a/apps/monograph/app/components/monograph-chat.tsx
+++ b/apps/monograph/app/components/monograph-chat.tsx
@@ -21,9 +21,10 @@ import { mdiTimerOutline } from "@mdi/js";
import { Icon } from "@notesnook/ui";
import { Flex, Image, Link, Text } from "@theme-ui/components";
import { SxProp } from "@theme-ui/core";
-import { PUBLIC_URL } from "../utils/env";
-export function MonographChat({ sx }: SxProp) {
+type Props = SxProp & { publicUrl: string };
+
+export function MonographChat({ sx, publicUrl }: Props) {
return (
<Flex
sx={{
@@ -62,7 +63,7 @@ export function MonographChat({ sx }: SxProp) {
borderRadius: 10,
width: "100%"
}}
- src={`${PUBLIC_URL}/api/og.jpg?title=Open+sourcing&description=VGhpcyBtb25vZ3JhcGggaXMgZW5jcnlwdGVkLiBFbnRlciBwYXNzd29yZCB0byB2aWV3IGNvbnRlbnRzLg%3D%3D&date=Saturday%2C+February+18%2C+2023`}
+ src={`${publicUrl}/api/og.jpg?title=Open+sourcing&description=VGhpcyBtb25vZ3JhcGggaXMgZW5jcnlwdGVkLiBFbnRlciBwYXNzd29yZCB0byB2aWV3IGNvbnRlbnRzLg%3D%3D&date=Saturday%2C+February+18%2C+2023`}
/>
<Text
mt="12px"
@@ -76,10 +77,10 @@ export function MonographChat({ sx }: SxProp) {
color: "accent",
overflowWrap: "anywhere"
}}
- href={`${PUBLIC_URL}/62db75572020209c36f9f9fb`}
+ href={`${publicUrl}/62db75572020209c36f9f9fb`}
target="_blank"
>
- {PUBLIC_URL}/62db75572020209c36f9f9fb
+ {publicUrl}/62db75572020209c36f9f9fb
</Link>
</Text>
<Timer time={"5m ago"} sx={{ mb: 1, mr: 1, alignSelf: "end" }} />
diff --git a/apps/monograph/app/routes/_index.tsx b/apps/monograph/app/routes/_index.tsx
index 26d8b0628..503d96491 100644
--- a/apps/monograph/app/routes/_index.tsx
+++ b/apps/monograph/app/routes/_index.tsx
@@ -38,6 +38,7 @@ import { Footer } from "../components/footer";
import { Header } from "../components/header";
import { ForwardRef } from "@theme-ui/components/dist/declarations/src/types";
import { PUBLIC_URL } from "../utils/env";
+import { useLoaderData } from "@remix-run/react";
export const meta: MetaFunction = () => {
return generateMetaDescriptors({
@@ -51,6 +52,10 @@ export const meta: MetaFunction = () => {
});
};
+export async function loader() {
+ return { publicUrl: PUBLIC_URL };
+}
+
const ButtonLink = Button as ForwardRef<
HTMLButtonElement,
ButtonProps & LinkProps
@@ -74,6 +79,8 @@ const features = [
}
];
export default function Monograph() {
+ const { publicUrl } = useLoaderData<typeof loader>();
+
return (
<Flex
sx={{
@@ -146,6 +153,7 @@ export default function Monograph() {
border: "1px solid var(--border)",
boxShadow: "0px -5px 15px 0px rgba(0,0,0,0.05)"
}}
+ publicUrl={publicUrl}
/>
</Flex>
<Box