diff --git a/.env.sample b/.env.sample index 91025f07..c900a32a 100644 --- a/.env.sample +++ b/.env.sample @@ -42,6 +42,7 @@ LNWITH_URL= NEXTAUTH_URL=http://localhost:3000/api/auth SELF_URL=http://app:3000 PUBLIC_URL=http://localhost:3000 +NEXT_PUBLIC_URL=http://localhost:3000 LND_CONNECT_ADDRESS=03cc1d0932bb99b0697f5b5e5961b83ab7fd66f1efc4c9f5c7bad66c1bcbe78f02@xhlmkj7mfrl6ejnczfwl2vqik3xim6wzmurc2vlyfoqw2sasaocgpuad.onion:9735 NEXTAUTH_SECRET=3_0W_PhDRZVanbeJsZZGIEljexkKoGbL6qGIqSwTjjI JWT_SIGNING_PRIVATE_KEY={"kty":"oct","kid":"FvD__hmeKoKHu2fKjUrWbRKfhjimIM4IKshyrJG4KSM","alg":"HS512","k":"3_0W_PhDRZVanbeJsZZGIEljexkKoGbL6qGIqSwTjjI"} diff --git a/api/ssrApollo.js b/api/ssrApollo.js index 127a4edd..8eeba5e1 100644 --- a/api/ssrApollo.js +++ b/api/ssrApollo.js @@ -79,7 +79,7 @@ export function getGetServerSideProps ( const { data: { me } } = await client.query({ query: ME }) if (authRequired && !me) { - const callback = process.env.PUBLIC_URL + req.url + const callback = process.env.NEXT_PUBLIC_URL + req.url return { redirect: { destination: `/signup?callbackUrl=${encodeURIComponent(callback)}` diff --git a/components/invite.js b/components/invite.js index 766a65cd..3f1fc8e2 100644 --- a/components/invite.js +++ b/components/invite.js @@ -21,7 +21,7 @@ export default function Invite ({ invite, active }) {
{invite.gift} sat gift diff --git a/components/share.js b/components/share.js index 2f69882f..ee9c1248 100644 --- a/components/share.js +++ b/components/share.js @@ -14,7 +14,7 @@ const referrurl = (ipath, me) => { if (!SSR) { return `${window.location.protocol}//${window.location.host}${path}` } - return `https://stacker.news${path}` + return `${process.env.NEXT_PUBLIC_URL}${path}` } export default function Share ({ path, title, className = '' }) { diff --git a/components/text.js b/components/text.js index 369be115..b68afd5c 100644 --- a/components/text.js +++ b/components/text.js @@ -19,7 +19,7 @@ import { rehypeInlineCodeProperty } from '@/lib/md' import { Button } from 'react-bootstrap' import { useRouter } from 'next/router' import Link from 'next/link' -import { SSR, UNKNOWN_LINK_REL } from '@/lib/constants' +import { UNKNOWN_LINK_REL } from '@/lib/constants' import isEqual from 'lodash/isEqual' export function SearchText ({ text }) { @@ -179,7 +179,7 @@ export default memo(function Text ({ rel, imgproxyUrls, children, tab, itemId, o // we don't render it as an image since it was probably a conscious choice to include text. const text = children[0] const url = !href.startsWith('/') && new URL(href) - const internalURL = SSR ? 'https://stacker.news' : window.location.origin + const internalURL = process.env.NEXT_PUBLIC_URL if (!!text && !/^https?:\/\//.test(text)) { if (props['data-footnote-ref'] || typeof props['data-footnote-backref'] !== 'undefined') { return ( diff --git a/components/user-header.js b/components/user-header.js index 440b7d5f..eafff82f 100644 --- a/components/user-header.js +++ b/components/user-header.js @@ -251,7 +251,7 @@ function HeaderHeader ({ user }) {
) - const lnurlp = encodeLNUrl(new URL(`https://stacker.news/.well-known/lnurlp/${user.name}`)) + const lnurlp = encodeLNUrl(new URL(`${process.env.NEXT_PUBLIC_URL}/.well-known/lnurlp/${user.name}`)) return (
diff --git a/lib/lnurl.js b/lib/lnurl.js index 11f4c07d..38b172dc 100644 --- a/lib/lnurl.js +++ b/lib/lnurl.js @@ -31,7 +31,7 @@ export async function lnAddrOptions (addr) { let protocol = 'https' if (process.env.NODE_ENV === 'development') { // support HTTP and HTTPS during development - protocol = process.env.PUBLIC_URL.split('://')[0] + protocol = process.env.NEXT_PUBLIC_URL.split('://')[0] } const unexpectedErrorMessage = `An unexpected error occurred fetching the Lightning Address metadata for ${addr}. Check the address and try again.` let res diff --git a/lib/url.js b/lib/url.js index 4cbb4ddb..36d2192c 100644 --- a/lib/url.js +++ b/lib/url.js @@ -1,5 +1,3 @@ -import { SSR } from './constants' - export function ensureProtocol (value) { if (!value) return value value = value.trim() @@ -10,7 +8,7 @@ export function ensureProtocol (value) { } export function isExternal (url) { - return !url.startsWith(process.env.PUBLIC_URL + '/') && !url.startsWith('/') + return !url.startsWith(process.env.NEXT_PUBLIC_URL + '/') && !url.startsWith('/') } export function removeTracking (value) { @@ -30,7 +28,7 @@ export function removeTracking (value) { */ export function parseInternalLinks (href) { const url = new URL(href) - const internalURL = SSR ? 'https://stacker.news' : window.location.origin + const internalURL = process.env.NEXT_PUBLIC_URL const { pathname, searchParams } = url // ignore empty parts which exist due to pathname starting with '/' const emptyPart = part => !!part diff --git a/pages/api/lnurlp/[username]/index.js b/pages/api/lnurlp/[username]/index.js index 20628fba..66d81c7b 100644 --- a/pages/api/lnurlp/[username]/index.js +++ b/pages/api/lnurlp/[username]/index.js @@ -10,7 +10,7 @@ export default async ({ query: { username } }, res) => { } return res.status(200).json({ - callback: `${process.env.PUBLIC_URL}/api/lnurlp/${username}/pay`, // The URL from LN SERVICE which will accept the pay request parameters + callback: `${process.env.NEXT_PUBLIC_URL}/api/lnurlp/${username}/pay`, // The URL from LN SERVICE which will accept the pay request parameters minSendable: 1000, // Min amount LN SERVICE is willing to receive, can not be less than 1 or more than `maxSendable` maxSendable: 1000000000, metadata: lnurlPayMetadataString(username), // Metadata json which must be presented as raw string here, this is required to pass signature verification at a later step diff --git a/pages/invites/[id].js b/pages/invites/[id].js index e7516249..21b9affd 100644 --- a/pages/invites/[id].js +++ b/pages/invites/[id].js @@ -53,7 +53,7 @@ export async function getServerSideProps ({ req, res, query: { id, error = null return { props: { providers: await getProviders(), - callbackUrl: process.env.PUBLIC_URL + req.url, + callbackUrl: process.env.NEXT_PUBLIC_URL + req.url, invite: data.invite, error } diff --git a/pages/login.js b/pages/login.js index 4daab48a..cfe49952 100644 --- a/pages/login.js +++ b/pages/login.js @@ -26,7 +26,7 @@ export async function getServerSideProps ({ req, res, query: { callbackUrl, erro // in the cause of auth linking we want to pass the error back to // settings if (error) { - const url = new URL(callbackUrl, process.env.PUBLIC_URL) + const url = new URL(callbackUrl, process.env.NEXT_PUBLIC_URL) url.searchParams.set('error', error) callbackUrl = url.pathname + url.search } diff --git a/pages/referrals/[when].js b/pages/referrals/[when].js index 47489103..0b647759 100644 --- a/pages/referrals/[when].js +++ b/pages/referrals/[when].js @@ -102,7 +102,7 @@ export default function Referrals ({ ssrData }) { groupClassName='mb-0 w-100' readOnly noForm - placeholder={`https://stacker.news/r/${me.name}`} + placeholder={`${process.env.NEXT_PUBLIC_URL}/r/${me.name}`} />