Skip to content
This repository has been archived by the owner on Oct 14, 2020. It is now read-only.
/ next-now-base-url Public archive

get the base url for your now.sh deployment in next.js

Notifications You must be signed in to change notification settings

mcansh/next-now-base-url

Repository files navigation

@mcansh/next-now-base-url

get the base url for your now.sh deployment in next.js

import { getBaseURL } from '@mcansh/next-now-base-url';
import fetch from 'isomorphic-unfetch';

const Index: NextPage = () => <h1>Hello</h1>;

Index.getInitialProps = async ({ req }) => {
  const base = getBaseURL(req);
  const data = await fetch(`${base}/api/something`);
  return { data };
};

export default Index;