Skip to content

Commit

Permalink
🐛 Fix 404 error page
Browse files Browse the repository at this point in the history
Wasn't working because of ssr prop from trpc
  • Loading branch information
baptisteArno committed Feb 14, 2023
1 parent 08e33fb commit eef015e
Show file tree
Hide file tree
Showing 8 changed files with 29 additions and 21 deletions.
1 change: 1 addition & 0 deletions apps/builder/.eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
next.config.js
10 changes: 10 additions & 0 deletions apps/builder/next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,15 @@ const nextConfig = withTM({
experimental: {
outputFileTracingRoot: path.join(__dirname, '../../'),
},
async redirects() {
return [
{
source: '/typebots/:typebotId',
destination: '/typebots/:typebotId/edit',
permanent: true,
},
]
},
headers: async () => {
return [
{
Expand All @@ -40,6 +49,7 @@ module.exports = process.env.NEXT_PUBLIC_SENTRY_DSN
...nextConfig,
sentry: {
hideSourceMaps: true,
widenClientFileUpload: true,
},
},
sentryWebpackPluginOptions
Expand Down
9 changes: 7 additions & 2 deletions apps/builder/src/lib/trpc.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { httpBatchLink } from '@trpc/client'
import { httpBatchLink, loggerLink } from '@trpc/client'
import { createTRPCNext } from '@trpc/next'
import type { AppRouter } from '../utils/server/routers/v1/trpcRouter'
import superjson from 'superjson'
Expand All @@ -10,12 +10,17 @@ export const trpc = createTRPCNext<AppRouter>({
config() {
return {
links: [
loggerLink({
enabled: (opts) =>
process.env.NODE_ENV === 'development' ||
(opts.direction === 'down' && opts.result instanceof Error),
}),
httpBatchLink({
url: `${getBaseUrl()}/api/trpc`,
}),
],
transformer: superjson,
}
},
ssr: true,
ssr: false,
})
1 change: 1 addition & 0 deletions apps/builder/src/pages/_app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ const App = ({
}, [isReady])

const typebotId = query.typebotId?.toString()

return (
<>
<ToastContainer />
Expand Down
14 changes: 4 additions & 10 deletions apps/builder/src/pages/_error.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
/**
* 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:
* - on the server, when data-fetching methods throw or reject
* - on the client, when `getInitialProps` throws or rejects
Expand All @@ -17,22 +14,19 @@
*/

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'

const CustomErrorComponent = (props: {
statusCode: number
hasGetInitialPropsRun: boolean
err: Error
}) => {
const CustomErrorComponent: NextPage<ErrorProps> = (props) => {
// 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
// Sentry.captureUnderscoreErrorException(props);

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
// time to send the error before the lambda exits
await Sentry.captureUnderscoreErrorException(contextData)
Expand Down
1 change: 1 addition & 0 deletions apps/viewer/.eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
next.config.js
1 change: 1 addition & 0 deletions apps/viewer/next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ module.exports = process.env.NEXT_PUBLIC_SENTRY_DSN
...nextConfig,
sentry: {
hideSourceMaps: true,
widenClientFileUpload: true,
},
},
sentryWebpackPluginOptions
Expand Down
13 changes: 4 additions & 9 deletions apps/viewer/src/pages/_error.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
/**
* 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:
* - on the server, when data-fetching methods throw or reject
* - on the client, when `getInitialProps` throws or rejects
Expand All @@ -17,21 +14,19 @@
*/

import * as Sentry from '@sentry/nextjs'
import type { NextPage } from 'next'
import type { ErrorProps } from 'next/error'
import NextErrorComponent from 'next/error'

const CustomErrorComponent = (props: {
statusCode: number
hasGetInitialPropsRun: boolean
err: Error
}) => {
const CustomErrorComponent: NextPage<ErrorProps> = (props) => {
// 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
// Sentry.captureUnderscoreErrorException(props);

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
// time to send the error before the lambda exits
await Sentry.captureUnderscoreErrorException(contextData)
Expand Down

4 comments on commit eef015e

@vercel
Copy link

@vercel vercel bot commented on eef015e Feb 14, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vercel
Copy link

@vercel vercel bot commented on eef015e Feb 14, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

docs – ./apps/docs

docs-git-main-typebot-io.vercel.app
docs-typebot-io.vercel.app
docs.typebot.io

@vercel
Copy link

@vercel vercel bot commented on eef015e Feb 14, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

viewer-v2 – ./apps/viewer

ns8.vn
1stop.au
yobot.me
klujo.com
247987.com
8jours.top
aginap.com
bee.cr8.ai
bot.aws.bj
bot.bbc.bj
cat.cr8.ai
finplex.be
pig.cr8.ai
app.yvon.earth
ar.nigerias.io
bot.enreso.org
bot.rslabs.pro
bots.bridge.ai
chat.hayuri.id
chicken.cr8.ai
gollum.riku.ai
gsbulletin.com
panther.cr7.ai
panther.cr8.ai
penguin.cr8.ai
talk.gocare.io
test.bot.gives
ticketfute.com
unicorn.cr8.ai
apo.nigerias.io
apr.nigerias.io
aso.nigerias.io
bot.ageenda.com
bot.artiweb.app
bot.devitus.com
bot.jesopizz.it
bot.reeplai.com
bot.scayver.com
bot.tc-mail.com
chat.lalmon.com
chat.sureb4.com
eventhub.com.au
fitness.riku.ai
games.klujo.com
help.taxtree.io
sakuranembro.it
typebot.aloe.do
bot.contakit.com
bot.piccinato.co
bot.sv-energy.it
botc.ceox.com.br
clo.closeer.work
cockroach.cr8.ai
faqs.nigerias.io
feedback.ofx.one
form.syncwin.com
haymanevents.com
kw.wpwakanda.com
myrentalhost.com
mainmenu1one.wpwakanda.com
tarian.theiofoundation.org
ted.meujalecobrasil.com.br
type.dericsoncalari.com.br
bot.pinpointinteractive.com
bot.polychromes-project.com
bot.seidinembroseanchetu.it
chatbot.berbelanjabiz.trade
designguide.techyscouts.com
liveconvert2.kandalearn.com
presente.empresarias.com.mx
sell.sellthemotorhome.co.uk
anamnese.odontopavani.com.br
austin.channelautomation.com
bot.marketingplusmindset.com
bot.seidibergamoseanchetu.it
desabafe.sergiolimajr.com.br
download.venturemarketing.in
piazzatorre.barrettamario.it
type.cookieacademyonline.com
bot.brigadeirosemdrama.com.br
forms.escoladeautomacao.com.br
onboarding.libertydreamcare.ie
type.talitasouzamarques.com.br
agendamento.sergiolimajr.com.br
anamnese.clinicamegasjdr.com.br
bookings.littlepartymonkeys.com
bot.comercializadoraomicron.com
elevateyourmind.groovepages.com
viewer-v2-typebot-io.vercel.app
yourfeedback.comebackreward.com
gerador.verificadordehospedes.com
personal-trainer.barrettamario.it
preagendamento.sergiolimajr.com.br
studiotecnicoimmobiliaremerelli.it
download.thailandmicespecialist.com
register.thailandmicespecialist.com
bot.studiotecnicoimmobiliaremerelli.it
pesquisa.escolamodacomproposito.com.br
anamnese.clinicaramosodontologia.com.br
viewer-v2-git-main-typebot-io.vercel.app

@vercel
Copy link

@vercel vercel bot commented on eef015e Feb 14, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

builder-v2 – ./apps/builder

builder-v2-typebot-io.vercel.app
builder-v2-git-main-typebot-io.vercel.app
app.typebot.io

Please sign in to comment.