ivandoric / Making-Websites-With-Next.js-And-Strapi

This is a repository for video tutorial series about Making Websites With Next.js and Strapi. You can check out the series here:
127 stars 47 forks source link

TypeError: Only absolute URLs are supported #5

Open p-null opened 4 years ago

p-null commented 4 years ago

Hi I git clone the master branch and do yarn to install node modules. When I do yarn dev I have the following error:

image

The console output:

index.js:247 Uncaught     at getNodeRequestOptions (file:///home/tingkai/nextjs_app/Making-Websites-With-Next.js-And-Strapi/node_modules/next/dist/compiled/node-fetch/index.js:1:145647)
    at <unknown> (file:///home/tingkai/nextjs_app/Making-Websites-With-Next.js-And-Strapi/node_modules/next/dist/compiled/node-fetch/index.js:1:147021)
    at new Promise (<anonymous>)
    at fetch (file:///home/tingkai/nextjs_app/Making-Websites-With-Next.js-And-Strapi/node_modules/next/dist/compiled/node-fetch/index.js:1:146956)
    at Function.module.exports../pages/_app.js.MyApp.getInitialProps (file:///home/tingkai/nextjs_app/Making-Websites-With-Next.js-And-Strapi/.next/server/pages/_app.js:2929:78)
    at loadGetInitialProps (file:///home/tingkai/nextjs_app/Making-Websites-With-Next.js-And-Strapi/node_modules/next/dist/next-server/lib/utils.js:5:101)
    at renderToHTML (file:///home/tingkai/nextjs_app/Making-Websites-With-Next.js-And-Strapi/node_modules/next/dist/next-server/server/render.js:22:1221)
    at processTicksAndRejections (internal/process/task_queues.js:93:5)
    at async (file:///home/tingkai/nextjs_app/Making-Websites-With-Next.js-And-Strapi/node_modules/next/dist/next-server/server/next-server.js:76:329)
    at async (file:///home/tingkai/nextjs_app/Making-Websites-With-Next.js-And-Strapi/node_modules/next/dist/next-server/server/next-server.js:75:142)

Do you have any thoughts on what could be wrong? Thanks!

Other info

OS: WSL2 Ubuntu 20.04 LTS
node: v14.5.0
ivandoric commented 4 years ago

Did you try hard coding the URL to your API instead of using PublicRuntimeConfig etc. Because your API_URL should be in .env file, and that file is not in the git repo. You need to create it yourself.