rocket-url
v1.1.0
Published
This module return the real custom host when you are using AWS Amplify with custom domains on Next JS using Server Side Rendering.
Downloads
22
Maintainers
Readme
This module return the real custom host when you are using AWS Amplify with custom domains on Next JS using Server Side Rendering.
Import module
import rocketUrl from 'rocket-url'
On getInitialProps
receive 'ctx' from AppContext NextJS
App.getInitialProps = async ({ ctx }) => { const { host, protocol, origin } = rocketUrl(ctx?.req)
return {
props: {
host,
protocol,
origin
}
}
}
On getServerSideProps
receive 'req' from AppContext NextJS
export async function getServerSideProps({ req, resolvedUrl }) { const { host, protocol, origin } = rocketUrl(req) const pathname = resolvedUrl
return {
props: {
host,
protocol,
origin,
pathname
}
}
}