Questions tagged [getserversideprops]

103 questions
8
votes
0 answers

Vercel 504 Bad Gateway Error Page though code works in dev mode

So I have built a Next app based on this NextJS example which means I have GraphQL routes and an Apollo server I use to fetch from the API in the app. The example shows how to fetch in getStaticProps() which works fine for me but I need to implement…
8
votes
0 answers

How can I safely replace getInitialProps with getServerSideProps / getStaticProps

The following sentence is very familiar to all of us: You should not use getInitialProps, but getServerSideProps instead. I have already build my app using getInitialProps and now I'm facing the following question: "Should I replace getInitialProps…
user3343396
  • 725
  • 2
  • 13
  • 25
4
votes
4 answers

Using GetServerSideProps with Next-Auth: TypeError: Cannot destructure property 'nextauth' of 'req.query' as it is undefined

I am using getServerSideProps function in next.js with Next-Auth and I'm getting a TypeError: TypeError: Cannot destructure property 'nextauth' of 'req.query' as it is undefined. When I checked using the console, it does indeed return undefined. I…
JujV
  • 63
  • 5
3
votes
0 answers

getserversideprops axios return Request failed with status code 404 but it work on useffect

I am fetching a big problem with axios in my project. I used axios for fetching data in getServerSideProps. but is it showing 'Request failed with status code 404', in the same time i also used axios in useEffect where it get data from api. export…
Jonayeid Khan
  • 31
  • 1
  • 1
2
votes
0 answers

Nextjs middleware rewrite page props sometimes undefined

Hope this finds yo well. I'm working on a multilang website with translated URLs. I'm on Next.js 13.3 To handle the translated rotues i'm using a middleware. ( I have a large number of rewrites/redirects and the config ones entirely broke client…
Tofuu
  • 45
  • 1
  • 7
2
votes
3 answers

NextJS + Apollo: How to get multiple queries on apolloClient.query inside getServerSideProps?

I'm currently learning NextJS + Apollo and I've been stuck on a problem. Since getInitialProps is not recommended I'm using getServerSideProps. Here I'm using this code in order to get the props server-side and populate the components: export async…
eripanci
  • 25
  • 1
  • 5
2
votes
0 answers

Nextjs is not rendering dynamic meta tags with the data using serverSideProps

hello folks i need some help regarding SEO in nextjs i am trying it for like 2 weeks or so but unable to do so i am getting the data from the backend in serverSideProps it is successfully loading the page but the crawlers are unable to pick it up…
2
votes
1 answer

getServerSideProps does not render dynamic pages in production, and show 404 error

I'm working with next.js, in development mode everything works fine, but in production mode I have a problem when rendering the pages dynamically. I have the following path inside the pages folder pages/user/[id], and this component is where I call…
2
votes
0 answers

Should NextJS getStaticProps be used to serve a user-make-content web app?

The original question was posted at Github discussion. But no one has answered the question yet. So let's try my luck here. Context I am trying to build a platform (a.k.a. web-2.0) website, where users will create the majority of the content, say…
Ivan Wang
  • 8,306
  • 14
  • 44
  • 56
1
vote
1 answer

SSR Function Works in Mozilla but Not in Chrome

I'm facing an issue with my Next.js project involving server-side rendering (SSR). In my application, I have a payment flow where the user is redirected to a bank page for payment. Upon returning to my page, I rely on an SSR function to retrieve and…
1
vote
2 answers

getServerSideProps props are undefined on client-side when using middleware

I'm trying to do a redirect on every page if a certain condition is true using Nextjs middleware. For some reason, whenever the matcher in middleware.ts matches a page, all props from getServerSideProps on that page are undefined when they reach the…
kennsorr
  • 292
  • 3
  • 20
1
vote
1 answer

Next.js test of using static and serverside props requires that I check for component props Object not null

I created a project to get familiar with Next.js getStaticProps and getServerSide props. I have a simple component that renders a table row based on user data. I haven't been able to detect a time when the object was null, but if I don't check for…
user1079785
  • 137
  • 2
  • 7
1
vote
1 answer

getServerSideProps from nextjs is never invoked

That is my code. I use prisma for fetching data from my postgreSQL db. The problem is that getServerSideProps is never invoked. The log message is not even printed in a console. The file is located in app folder *page.tsx* import Header from…
ArtemBohak
  • 79
  • 6
1
vote
0 answers

Is it possible to first time data get from cache using getServerSideProps?

export async function getServerSideProps({ req, res }) { res.setHeader( 'Cache-Control', 'public, max-age=1800, stale-while-revalidate=59' ) const resq = await…
1
vote
1 answer

getServerSideProps implementation resulting different props

I'm new in using NextJS and still learning about SSR, i had hard time understanding getServerSideProps() functionality, it's says that should replace useState for it be rendered on backend, but i got different props from what i gave to it and…
1
2 3 4 5 6 7