Questions tagged [getserversideprops]
103 questions
0
votes
0 answers
How to use getServerSideProps when it required argument is from Page in Nextjs
I am calling the internal API route by passing the searchParams to search the database (api/model/route.js):
import { connectToDB } from "@/app/utils/database";
import Events from "@/models/events";
import { NextRequest } from "next/server";
export…

TungTung
- 163
- 7
0
votes
0 answers
2nd request to getServerSideProps fails to update/hydrate in Next.js
I am using a component to render a page, and I am using dynamic routes. I am pre-rendering using getServerSideProps, and now data of the page can change based on the route.
When the page is first loaded, the SSR returns HTML and the data and…

kartik sachdeva
- 1
- 1
0
votes
0 answers
Extract TLD from hostname string
I have the following hostnames and they TLDs.
dev.sitename.com (.com)
sitename.com (.com)
sitename.co.uk (.co.uk)
dev.sitename.co.uk (.co.uk)
staging.sitename.k34.com (.com)
local.sitename.com:3000 (.com) - (Is used on local webserver virtual host…

mcclosa
- 943
- 7
- 29
- 59
0
votes
0 answers
getSercerSideProps not wroking Nextjs 13
I want to get content from Contentful using getServerSideProps in Next.js 13. However, when I try to console.log the value, it shows undefined. If I fetch the data inside the SalesTaxArticle component, it works fine, but I'm concerned about the…

Luis Gonzalez
- 11
- 1
0
votes
1 answer
Does Next.js SSR caching store all data or just the returned data?
I'm working with an API that come with a pagination function but doesn't sort data based on the client's requirements. To work around this I'm fetching all data from the API inside getServerSideProps and only returning a portion of the data based on…

muhammadarifftaha
- 15
- 5
0
votes
0 answers
Next.js getServerSideProps returns empty query object when I pressed go back button
On the first page, I do router.replace() with new a query. so the URL becomes similar to someUrl?timestamp=1000.
After this I move to second page with router.push() and press back button on the browser, which takes me back to…

Gianna
- 205
- 2
- 12
0
votes
0 answers
GetServerSideProps NextJs brokens in production
I have getServerSideProps function in NextJs12 looks like:
export const getServerSideProps: GetServerSideProps = async (ctx) => {
const shouldRedirect = await checkPermission({ permissionCode: PERMISSION_CODES.CA_MANAGE, type: 'create' },…

Sy__26_6
- 1
- 2
0
votes
1 answer
NextJS White Screen on pages with getServerSideProps when URL Put in Browser Directly
I am using Next 13 and I am facing issue when production build only. Basically site works fine but when I try to open a page by URL typing in browser it shows empty page or white screen. Upon checking the browser console I see a keyword undefined…

Manoj Sethi
- 1,898
- 8
- 26
- 56
0
votes
0 answers
This Serverless Function has timed out in Next app
I'm using getServerSideProps' to get a parameter in the URL, no big deal, but when I upload my application to Vercel (Hobby plan) I have the following problem
This Serverless Function has timed out.
Your connection is working correctly.
Vercel is…

iWozzming
- 13
- 3
0
votes
1 answer
How to load Runtime environmental variables in NextJS application
I am deploying a NextJS app in various K8 environments, each passing it's own variables. I can pass them in and get them with getServerSideProps(), but as this function works on page components (or at least that's what the docs say), I have to add…

Mike M
- 4,879
- 5
- 38
- 58
0
votes
2 answers
next js console about getServerSideProps props
Can I check the value in terminal if I take console of the value received through getServerSideProps in the page component?
ex)
export const getServerSideProps = async({ req, res }) => {
const data = useHook();
// data = 1;
return {
data
…

jihwan
- 57
- 1
- 5
0
votes
1 answer
Common Dynamic Header in Next JS
I have started on Next JS. I am using a common header.js component and included it in _app.js so that it gets rendered all created pages.
Now I want to make my header dynamic, that is navigation items should be fetched from db and rendered. I tried…

Souvik Banerjee
- 187
- 1
- 3
- 14
0
votes
0 answers
getServerSideProps called on state change
I'm using getServerSideProps with next-redux-wrapper.
The issue is it invokes when I change the state on the button click.
as of my understanding, it should invoke only when we visit the page directly or navigate through the next link or route.
here…

yograj tandel
- 143
- 8
0
votes
1 answer
rss.xml file in public fold of Nextjs goes to 404 after deploying to Vercel
I was able to generate an rss.xml file and write it fs.writefilesync. When viewed locally, it works, but on vercel, the build breaks and says "no such file or director ./public/rss.xml."
If I commnet out the fs.writefilesync line, the deployment and…

Tongene
- 1
- 2
0
votes
0 answers
Having issue fetching comment from sanity.io across all pages in Next Js
I have collections of comments from sanity.io, am trying to fetch the comments to make them available on all pages. I tried fetching it in the _app.tsx using getServerProps but am receiving undefined. I then tried using useEffect but same thing is…

Rengkat
- 23
- 8