🐛 Fix 404 error page
Wasn't working because of ssr prop from trpc
This commit is contained in:
1
apps/builder/.eslintignore
Normal file
1
apps/builder/.eslintignore
Normal file
@ -0,0 +1 @@
|
|||||||
|
next.config.js
|
@ -14,6 +14,15 @@ const nextConfig = withTM({
|
|||||||
experimental: {
|
experimental: {
|
||||||
outputFileTracingRoot: path.join(__dirname, '../../'),
|
outputFileTracingRoot: path.join(__dirname, '../../'),
|
||||||
},
|
},
|
||||||
|
async redirects() {
|
||||||
|
return [
|
||||||
|
{
|
||||||
|
source: '/typebots/:typebotId',
|
||||||
|
destination: '/typebots/:typebotId/edit',
|
||||||
|
permanent: true,
|
||||||
|
},
|
||||||
|
]
|
||||||
|
},
|
||||||
headers: async () => {
|
headers: async () => {
|
||||||
return [
|
return [
|
||||||
{
|
{
|
||||||
@ -40,6 +49,7 @@ module.exports = process.env.NEXT_PUBLIC_SENTRY_DSN
|
|||||||
...nextConfig,
|
...nextConfig,
|
||||||
sentry: {
|
sentry: {
|
||||||
hideSourceMaps: true,
|
hideSourceMaps: true,
|
||||||
|
widenClientFileUpload: true,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
sentryWebpackPluginOptions
|
sentryWebpackPluginOptions
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { httpBatchLink } from '@trpc/client'
|
import { httpBatchLink, loggerLink } from '@trpc/client'
|
||||||
import { createTRPCNext } from '@trpc/next'
|
import { createTRPCNext } from '@trpc/next'
|
||||||
import type { AppRouter } from '../utils/server/routers/v1/trpcRouter'
|
import type { AppRouter } from '../utils/server/routers/v1/trpcRouter'
|
||||||
import superjson from 'superjson'
|
import superjson from 'superjson'
|
||||||
@ -10,6 +10,11 @@ export const trpc = createTRPCNext<AppRouter>({
|
|||||||
config() {
|
config() {
|
||||||
return {
|
return {
|
||||||
links: [
|
links: [
|
||||||
|
loggerLink({
|
||||||
|
enabled: (opts) =>
|
||||||
|
process.env.NODE_ENV === 'development' ||
|
||||||
|
(opts.direction === 'down' && opts.result instanceof Error),
|
||||||
|
}),
|
||||||
httpBatchLink({
|
httpBatchLink({
|
||||||
url: `${getBaseUrl()}/api/trpc`,
|
url: `${getBaseUrl()}/api/trpc`,
|
||||||
}),
|
}),
|
||||||
@ -17,5 +22,5 @@ export const trpc = createTRPCNext<AppRouter>({
|
|||||||
transformer: superjson,
|
transformer: superjson,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
ssr: true,
|
ssr: false,
|
||||||
})
|
})
|
||||||
|
@ -47,6 +47,7 @@ const App = ({
|
|||||||
}, [isReady])
|
}, [isReady])
|
||||||
|
|
||||||
const typebotId = query.typebotId?.toString()
|
const typebotId = query.typebotId?.toString()
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<ToastContainer />
|
<ToastContainer />
|
||||||
|
@ -1,9 +1,6 @@
|
|||||||
/**
|
/**
|
||||||
* NOTE: This requires `@sentry/nextjs` version 7.3.0 or higher.
|
* NOTE: This requires `@sentry/nextjs` version 7.3.0 or higher.
|
||||||
*
|
*
|
||||||
* NOTE: If using this with `next` version 12.2.0 or lower, uncomment the
|
|
||||||
* penultimate line in `CustomErrorComponent`.
|
|
||||||
*
|
|
||||||
* This page is loaded by Nextjs:
|
* This page is loaded by Nextjs:
|
||||||
* - on the server, when data-fetching methods throw or reject
|
* - on the server, when data-fetching methods throw or reject
|
||||||
* - on the client, when `getInitialProps` throws or rejects
|
* - on the client, when `getInitialProps` throws or rejects
|
||||||
@ -17,14 +14,11 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import * as Sentry from '@sentry/nextjs'
|
import * as Sentry from '@sentry/nextjs'
|
||||||
import { NextPageContext } from 'next'
|
import type { NextPage } from 'next'
|
||||||
|
import type { ErrorProps } from 'next/error'
|
||||||
import NextErrorComponent from 'next/error'
|
import NextErrorComponent from 'next/error'
|
||||||
|
|
||||||
const CustomErrorComponent = (props: {
|
const CustomErrorComponent: NextPage<ErrorProps> = (props) => {
|
||||||
statusCode: number
|
|
||||||
hasGetInitialPropsRun: boolean
|
|
||||||
err: Error
|
|
||||||
}) => {
|
|
||||||
// If you're using a Nextjs version prior to 12.2.1, uncomment this to
|
// If you're using a Nextjs version prior to 12.2.1, uncomment this to
|
||||||
// compensate for https://github.com/vercel/next.js/issues/8592
|
// compensate for https://github.com/vercel/next.js/issues/8592
|
||||||
// Sentry.captureUnderscoreErrorException(props);
|
// Sentry.captureUnderscoreErrorException(props);
|
||||||
@ -32,7 +26,7 @@ const CustomErrorComponent = (props: {
|
|||||||
return <NextErrorComponent statusCode={props.statusCode} />
|
return <NextErrorComponent statusCode={props.statusCode} />
|
||||||
}
|
}
|
||||||
|
|
||||||
CustomErrorComponent.getInitialProps = async (contextData: NextPageContext) => {
|
CustomErrorComponent.getInitialProps = async (contextData) => {
|
||||||
// In case this is running in a serverless function, await this in order to give Sentry
|
// In case this is running in a serverless function, await this in order to give Sentry
|
||||||
// time to send the error before the lambda exits
|
// time to send the error before the lambda exits
|
||||||
await Sentry.captureUnderscoreErrorException(contextData)
|
await Sentry.captureUnderscoreErrorException(contextData)
|
||||||
|
1
apps/viewer/.eslintignore
Normal file
1
apps/viewer/.eslintignore
Normal file
@ -0,0 +1 @@
|
|||||||
|
next.config.js
|
@ -27,6 +27,7 @@ module.exports = process.env.NEXT_PUBLIC_SENTRY_DSN
|
|||||||
...nextConfig,
|
...nextConfig,
|
||||||
sentry: {
|
sentry: {
|
||||||
hideSourceMaps: true,
|
hideSourceMaps: true,
|
||||||
|
widenClientFileUpload: true,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
sentryWebpackPluginOptions
|
sentryWebpackPluginOptions
|
||||||
|
@ -1,9 +1,6 @@
|
|||||||
/**
|
/**
|
||||||
* NOTE: This requires `@sentry/nextjs` version 7.3.0 or higher.
|
* NOTE: This requires `@sentry/nextjs` version 7.3.0 or higher.
|
||||||
*
|
*
|
||||||
* NOTE: If using this with `next` version 12.2.0 or lower, uncomment the
|
|
||||||
* penultimate line in `CustomErrorComponent`.
|
|
||||||
*
|
|
||||||
* This page is loaded by Nextjs:
|
* This page is loaded by Nextjs:
|
||||||
* - on the server, when data-fetching methods throw or reject
|
* - on the server, when data-fetching methods throw or reject
|
||||||
* - on the client, when `getInitialProps` throws or rejects
|
* - on the client, when `getInitialProps` throws or rejects
|
||||||
@ -17,13 +14,11 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import * as Sentry from '@sentry/nextjs'
|
import * as Sentry from '@sentry/nextjs'
|
||||||
|
import type { NextPage } from 'next'
|
||||||
|
import type { ErrorProps } from 'next/error'
|
||||||
import NextErrorComponent from 'next/error'
|
import NextErrorComponent from 'next/error'
|
||||||
|
|
||||||
const CustomErrorComponent = (props: {
|
const CustomErrorComponent: NextPage<ErrorProps> = (props) => {
|
||||||
statusCode: number
|
|
||||||
hasGetInitialPropsRun: boolean
|
|
||||||
err: Error
|
|
||||||
}) => {
|
|
||||||
// If you're using a Nextjs version prior to 12.2.1, uncomment this to
|
// If you're using a Nextjs version prior to 12.2.1, uncomment this to
|
||||||
// compensate for https://github.com/vercel/next.js/issues/8592
|
// compensate for https://github.com/vercel/next.js/issues/8592
|
||||||
// Sentry.captureUnderscoreErrorException(props);
|
// Sentry.captureUnderscoreErrorException(props);
|
||||||
@ -31,7 +26,7 @@ const CustomErrorComponent = (props: {
|
|||||||
return <NextErrorComponent statusCode={props.statusCode} />
|
return <NextErrorComponent statusCode={props.statusCode} />
|
||||||
}
|
}
|
||||||
|
|
||||||
CustomErrorComponent.getInitialProps = async (contextData: any) => {
|
CustomErrorComponent.getInitialProps = async (contextData) => {
|
||||||
// In case this is running in a serverless function, await this in order to give Sentry
|
// In case this is running in a serverless function, await this in order to give Sentry
|
||||||
// time to send the error before the lambda exits
|
// time to send the error before the lambda exits
|
||||||
await Sentry.captureUnderscoreErrorException(contextData)
|
await Sentry.captureUnderscoreErrorException(contextData)
|
||||||
|
Reference in New Issue
Block a user