import { GetServerSidePropsContext } from 'next';

/**
 * 環境変数からads.txtを生成
 * @see https://zenn.dev/catnose99/articles/c441954a987c24
 */
export const getServerSideProps = async ({ res }: GetServerSidePropsContext) => {
  const text = `google.com, ${process.env.NEXT_PUBLIC_AD_CLIENT}, DIRECT, ${process.env.ADSTEXT_ID}`;
  res.statusCode = 200;
  res.setHeader('Cache-Control', 's-maxage=86400, stale-while-revalidate');
  res.setHeader('Content-Type', 'text/plain');
  res.end(text);
  return {
    props: {},
  };
};

const Page = () => null;
export default Page;
