Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- static async getInitialProps({ Component: { getInitialProps }, ctx }) {
- const pageProps = await (async () =>
- getInitialProps ? await getInitialProps(ctx) : {})();
- const { req, res, asPath, query, pathname: ctxPathname } = ctx;
- handleRedirect({ res, query });
- const userAgent = req ? req.headers['user-agent'] : navigator.userAgent;
- // @TODO: Review this change on FE_URL constant, due to SSR proxy
- // const hostname = req ? req.get('host') : window.location.hostname;
- // const host = req ? req.get('Host') : window.location.host;
- // const protocol = req ? `${req.protocol}:` : window.location.protocol;
- // const origin = `${protocol}//${host}`;
- const { protocol, host, hostname, origin } = new Url(FE_URL);
- const { pathname, query: urlQuery } = new Url(asPath, true);
- const href = origin + asPath;
- return {
- pageProps,
- origin,
- url: {
- protocol,
- href,
- hostname,
- host,
- origin,
- pathname,
- query: urlQuery,
- },
- userAgent,
- asPath,
- pathname: ctxPathname,
- query,
- };
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement