rocket-url

1.1.0 • Public • Published

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
    }
}

}

Package Sidebar

Install

npm i rocket-url

Weekly Downloads

5

Version

1.1.0

License

ISC

Unpacked Size

2.51 kB

Total Files

3

Last publish

Collaborators

  • ccoopman