2021-09-30 12:28:30 +00:00
|
|
|
import { httpBatchLink } from "@trpc/client/links/httpBatchLink";
|
|
|
|
import { loggerLink } from "@trpc/client/links/loggerLink";
|
|
|
|
import { withTRPC } from "@trpc/next";
|
2021-09-23 08:49:17 +00:00
|
|
|
import { appWithTranslation } from "next-i18next";
|
2021-08-27 12:35:20 +00:00
|
|
|
import { DefaultSeo } from "next-seo";
|
2021-09-22 19:52:38 +00:00
|
|
|
import type { AppProps as NextAppProps } from "next/app";
|
|
|
|
|
|
|
|
import AppProviders from "@lib/app-providers";
|
2021-08-27 12:35:20 +00:00
|
|
|
import { seoConfig } from "@lib/config/next-seo.config";
|
2021-03-10 10:02:39 +00:00
|
|
|
|
2021-09-22 19:52:38 +00:00
|
|
|
import "../styles/globals.css";
|
|
|
|
|
2021-09-09 13:51:06 +00:00
|
|
|
// Workaround for https://github.com/vercel/next.js/issues/8592
|
2021-08-27 12:11:24 +00:00
|
|
|
export type AppProps = NextAppProps & {
|
|
|
|
/** Will be defined only is there was an error */
|
|
|
|
err?: Error;
|
|
|
|
};
|
|
|
|
|
2021-09-27 14:47:55 +00:00
|
|
|
function MyApp(props: AppProps) {
|
|
|
|
const { Component, pageProps, err } = props;
|
2021-03-24 15:03:04 +00:00
|
|
|
return (
|
2021-09-27 14:47:55 +00:00
|
|
|
<AppProviders {...props}>
|
2021-08-27 12:35:20 +00:00
|
|
|
<DefaultSeo {...seoConfig.defaultNextSeo} />
|
2021-08-27 12:11:24 +00:00
|
|
|
<Component {...pageProps} err={err} />
|
|
|
|
</AppProviders>
|
2021-04-11 17:12:18 +00:00
|
|
|
);
|
2021-03-10 10:02:39 +00:00
|
|
|
}
|
|
|
|
|
2021-09-30 12:28:30 +00:00
|
|
|
export default withTRPC({
|
|
|
|
config() {
|
|
|
|
/**
|
|
|
|
* If you want to use SSR, you need to use the server's full URL
|
|
|
|
* @link https://trpc.io/docs/ssr
|
|
|
|
*/
|
|
|
|
return {
|
|
|
|
/**
|
|
|
|
* @link https://trpc.io/docs/links
|
|
|
|
*/
|
|
|
|
links: [
|
|
|
|
// adds pretty logs to your console in development and logs errors in production
|
|
|
|
loggerLink({
|
|
|
|
enabled: (opts) =>
|
|
|
|
process.env.NODE_ENV === "development" ||
|
|
|
|
(opts.direction === "down" && opts.result instanceof Error),
|
|
|
|
}),
|
|
|
|
httpBatchLink({
|
|
|
|
url: `/api/trpc`,
|
|
|
|
}),
|
|
|
|
],
|
|
|
|
/**
|
|
|
|
* @link https://react-query.tanstack.com/reference/QueryClient
|
|
|
|
*/
|
|
|
|
// queryClientConfig: { defaultOptions: { queries: { staleTime: 6000 } } },
|
|
|
|
};
|
|
|
|
},
|
|
|
|
/**
|
|
|
|
* @link https://trpc.io/docs/ssr
|
|
|
|
*/
|
|
|
|
ssr: false,
|
|
|
|
})(appWithTranslation(MyApp));
|