[英]getServerSideProps props are undefined on client-side when using middleware
賞金將在 6 天后到期。 此問題的答案有資格獲得+50聲望賞金。 kennsorr想讓更多人關注這個問題。 如果使用 Nextjs 中間件滿足特定條件,我將嘗試在每個頁面上進行重定向。 出於某種原因,每當 middleware.ts 中的matcher匹配頁面時,該頁面上getServerSid ...
[英]getServerSideProps props are undefined on client-side when using middleware
賞金將在 6 天后到期。 此問題的答案有資格獲得+50聲望賞金。 kennsorr想讓更多人關注這個問題。 如果使用 Nextjs 中間件滿足特定條件,我將嘗試在每個頁面上進行重定向。 出於某種原因,每當 middleware.ts 中的matcher匹配頁面時,該頁面上getServerSid ...
[英]how to correctly fetch data in getServerSideProps
使用 Next.js 我遇到了這個問題: 一到達pages/users ,我就收到了這個錯誤 我正在嘗試從getServerSideProps獲取所有用戶,內部頁面/用戶 api端點的文件夾結構如下-> api/users/index.js 在pages/users文件夾下,我有一個[id] ...
[英]pass object from one page to another page NextJS
我想將嵌套的 object 數據從一頁傳遞到下一頁。 我想傳遞 object。我們不能使用 localStorage 或 sessionStorage,因為我們必須使用 getServerSideProps 中的 object 值。 我們在這里不使用路由器查詢,因為它傳遞了一個采用密鑰對值的查詢。 ...
[英]versel does not return i18nexus key values from the getServerSideProps nextjs method
我遇到了這個問題:我使用 next-i18next 為我的站點添加了一個翻譯,以便開發更快,我使用了 i18nexus。 當我開發應用程序時,我沒有任何問題。 但是當上傳到 Versel 時,i18nexus 的值根本不顯示(只輸出鍵的名稱)。 對於 output,我使用 getServerSide ...
[英]Is possible to use getServerSideProps on client components inside app dir?
所以基本上我想在應用程序目錄中的客戶端組件上使用 getServerSideProps 如果我在終端和瀏覽器控制台中控制台記錄 props.data,這將返回未定義。 我不知道我是否在這里做錯了什么。 我要獲取的 api 是內部的。 我嘗試在服務器組件上使用 getServerSideProps ...
[英]Use getServerSideProps in Dynamic Routes
我正在嘗試在我的文件[username].js (使用動態路由)中使用getServerSideProps 。 要在next.js中使用動態路由,需要用到getStaticPaths()和getStaticProps({ params })這兩個函數。 但是,您不能將getServerSidePr ...
[英]How to pass fetched data to getServerSideProps function?
我正在使用 Context API 獲取數據,然后將數據傳遞給getServerSideProps function 但出現以下錯誤: React Hook "useContext" is called in function "getServerSideProps" that is neithe ...
[英]How can I resolve the error of 'serializing' from getServerSideProps in Next.js
我剛剛將服務器從const server = "https://backend.yourguide.pk"更改為const server = "https://stage.yourguide.pk" ,現在顯示此錯誤。 如何解決? getServerSideProps 的代碼: 錯誤 - Seri ...
[英]Error prerendering NextJS with Context and Firestore
我正在嘗試將我的 React 簡單電子商務應用程序轉換為 NextJS,但在弄清楚如何在使用 Context 時預呈現我的產品數據時遇到了問題。 問題是,我不需要像基於訂單的產品數量那樣的動態更新系統,因為這只是一個演示應用程序,所以我應該能夠預渲染所有內容並使用 getStaticProps 和 ...
[英]Why pageProps in NextJS page component is not being passed?
我有index.js頁面,我在其中使用getServerSideProps()通過 graphql 獲取 Strapi 數據。由於某種原因, props object 變空了。 我已經正確配置_app.js並且我肯定會使用 SSR 返回值。 index.js _app.js 那么,我做錯了什么還是 ...
[英]I have an error 401 with getServerSideProps with Jenkins CD
我想為我的網站安裝 CI/CD(帶有 NextJS、apollo-graphql、prisma 的全棧),所以我在我的服務器上安裝了 jenkins。 我安裝了 nginx 和 pm2 來啟動/重啟我的網站。 當我以 root 用戶啟動服務器時,一切正常,我在前端獲取數據沒有問題。 之后,我決定在 ...
[英]I keep getting ""Cannot read properties of undefined (reading 'map')""
我目前正在使用 Nextjs 13 來構建我的前端,我想從鏈接中獲取 a.joson 並使用它來使用服務器端渲染來填充我的網站,但我不斷收到此錯誤“無法讀取未定義的屬性(讀取'地圖')" 當我使用 getstaticprops 時一切正常,但是當我使用 getserversideprops 時遇到 ...
[英]How to use query param as a variable in groq sanity query inside getServerSideprops in next js?
我正在嘗試在我的博客項目中實現搜索功能,但在 getServersideprops 內的 groq 查詢(健全性)中使用變量時遇到問題。 這是我的代碼 這是我得到的錯誤 **服務器錯誤 ClientError:參數 $search 被引用,但未提供 ** 但是當用實際字符串替換變量時,我會成功獲得 ...
[英]How to improve SEO with getServerSideProps() in NextJS?
我有一個網站會顯示動態數據(文章),即每小時變化的數據。 因此,我選擇使用 NextJS 的getServerSideProps() 。 我無法使用getStaticPaths()因為數據變化如此頻繁,在構建站點一小時后,所有 static 路徑將指向過期文章,並且所有新文章都沒有任何指向它們的路 ...
[英]GetServerSideProps not getting called for nested page in Next with Typescript
我在 /article/[id] 處設置了一個頁面,該頁面應該使用 getServerSideProps 獲取該 id 的文章。 似乎根本沒有調用 getServerSideProps,因為我沒有看到任何控制台日志。 當我導航到該頁面時,它顯示“TypeError:無法讀取未定義的屬性(讀取'標題 ...
[英]When to use getStaticProps and getServerSide props in real world scenario
您好,我是 Next.js 的新手,我知道在 getStaticProps Next.js 將在構建時預渲染此頁面,在 getServerSideProps Next.js 中,將使用獲取服務器返回的每個請求的數據預渲染此頁面但我想要一個何時使用 getStaticProps 和 getServer ...
[英]Unhandled Runtime Error TypeError: can't access property "email", user is undefined [NEXTJS]
我的下一個應用程序中有一個 /session/profile 路由,只要有用戶登錄,它就會呈現一個名為 UserProfile 的組件: profile.js import { useRouter } from 'next/router'; import React, { useEffect ...
[英]Is there some way to read props from the server when _app loads
我想根據我的 /pages 目錄創建一個動態導航菜單,以在我添加新文件時掃描文件夾並自動更新菜單鏈接。 我正在分階段嘗試。 第 1 階段:我創建了一個獨立的導航欄頁面,它有自己的 getServerSideProps 來讀取文件系統並返回 /pages。 這工作正常。 第 2 階段:我希望在每個頁面 ...
[英]How to Fix Pages with `getServerSideProps` can not be exported
我有一個 Next Js 應用程序,其中包含帶有 getServerSideProps 的頁面。 我現在正在嘗試 npm 運行構建並將 npm 導出,這樣我就可以獲取“Out”文件夾並將其托管在 firebase 上,但在pages with "getServerSideProps" can not ...
[英]How to get cookies in getServerSideProps NextJS
在我的用戶頁面中,我使用getServerSideProps來獲取用戶的數據。 在第 1 號console.log中,您可以看到帶有令牌的cookies存在。 但是在 console.log 編號 2 cookies是空的我也在useEffect中做了同樣的請求,它按我的預期工作。 在consol ...