ACPixel
09/18/2021, 4:29 AMNEXT_PUBLIC_API_URI: '{{ NEXT_PUBLIC_API_URI }}'
) as such any fetch's that I have in next are throwing a Only absolute URLs are supported
error. Any help would be greatly appreciated 🙂thdxr
09/18/2021, 4:30 AMthdxr
09/18/2021, 4:30 AMthdxr
09/18/2021, 4:31 AMACPixel
09/18/2021, 4:31 AMgetStaticProps
and without it there during build time it doesn't have themACPixel
09/18/2021, 4:31 AMthdxr
09/18/2021, 4:32 AMACPixel
09/18/2021, 4:32 AMenvironment: {
NEXT_PUBLIC_API_URI: api.customDomainUrl!,
NEXT_PUBLIC_CMS_URI: process.env.CMS_URI!,
}
For context this is the only env I have in thereACPixel
09/18/2021, 4:33 AMACPixel
09/18/2021, 4:34 AM.env.production
in the Nextjs dir butACPixel
09/18/2021, 4:36 AMACPixel
09/18/2021, 4:43 AMthdxr
09/18/2021, 4:50 AMACPixel
09/18/2021, 4:59 AMthdxr
09/18/2021, 5:54 AMthdxr
09/18/2021, 5:55 AMthdxr
09/18/2021, 5:55 AMFrank
Frank
NEXT_PUBLIC_API_URI
in ur Next.js app?ACPixel
09/19/2021, 5:35 PMexport const getStaticProps: GetStaticProps = async (ctx) => {
if (process.env.NODE_ENV === "development") {
//@ts-ignore
process.env["NODE_TLS_REJECT_UNAUTHORIZED"] = 0;
}
let _locale = ctx.locale;
let topThree = await (
await fetch(
`${process.env.NEXT_PUBLIC_CMS_URI}/Reviews?_limit=3&_locale=${_locale}`
)
).json();
let pageInfo = await (
await fetch(
`${process.env.NEXT_PUBLIC_CMS_URI}/home-page?_locale=${_locale}`
)
).json();
return {
revalidate: 120,
props: {
topThree,
pageInfo,
},
};
};
ACPixel
09/19/2021, 5:39 PMFrank
getServerSideProps
, getStaticProps
needs the values at build time. And reading deployed values at build time is tricky.Frank
NEXT_PUBLIC_CMS_URI
wouldn’t exist on the first deploy b/c the API hasn’t been deployed yet.Frank
NEXT_PUBLIC_CMS_URI
could change at deploy time, so you could be reading a wrong value at build time.Frank
getStaticProps
to read from SSM.Frank
ACPixel
09/25/2021, 2:56 AMACPixel
09/25/2021, 2:56 AM