2
0

fix(viewer): 🐛 Ignoring port number when checking matching URL

This commit is contained in:
Baptiste Arnaud
2022-05-20 15:37:39 -07:00
parent 0f06aae80c
commit 62162c6c2a

View File

@ -15,7 +15,9 @@ export const getServerSideProps: GetServerSideProps = async (
if (!context.req.headers.host) return { props: {} }
const viewerUrls = (process.env.NEXT_PUBLIC_VIEWER_URL ?? '').split(',')
const isMatchingViewerUrl = viewerUrls.some((url) =>
context.req.headers.host?.includes(url.split('//')[1])
(context.req.headers.host ?? '')
.split(':')[0]
.includes(url.split('//')[1].split(':')[0])
)
const customDomain = `${context.req.headers.host}${
pathname === '/' ? '' : pathname
@ -27,7 +29,7 @@ export const getServerSideProps: GetServerSideProps = async (
console.log(
isMatchingViewerUrl
? `Couldn't find publicId: ${context.query.publicId?.toString()}`
: `Couldn't customDomain: ${customDomain}`
: `Couldn't find customDomain: ${customDomain}`
)
return {
props: {