Error: The reference 'GetServerSideProps' is being incorrectly used as a type instead of a value. Perhaps you intended to use 'typeof GetServerSideProps' instead?

Index.tsx

import Image from 'next/image'
import Head  from "next/head"
import { sanityClient, urlFor  } from "../sanity"
import Link from 'next/link'
import {Collection, address} from '../typings';
import  GetServerSideProps  from 'next';

interface props {
  collections: Collection

}

const Home=({collections}: props) => {
  return (

    
  <div className='bg-yellow-400 max-auto  flex min-h-screen flex-col py-10 px-10 '>
      <Head>
        <title>Ordinal Cats</title>
        <link rel="stylesheet" href="/fevicon.ico" />
      </Head>

      
        <h1 className='w-52 text-xl font-extralight sm:w-80 py-5'>
          <span className='font-extrabold underline decoration-orange-600/50'>Ordinal Cats</span>
        </h1>        
   

      <main className='bg-orange-500 rounded-lg p-10 shadow-xl shadow-black items-center ' >
        <div className='grid space-x-3 md:grid-cols-1 lg:grid-cols-1 2xl:grid-cols-4'>
          {collections?.map(collection => (

            
            <div key={collection.slug.current} className='flex flex-col items-center'>
              <img className='h-70 w-50 rounded-2xl object-cover' src={urlFor(collection.mainImage).url()} alt="" />
            <div>
            <h2 className='text-3xl items-center text-center'>{collection.title}</h2>
            <p className='mt-2 text-sm text-white text-center'>{collection.description}</p>
            <Link href={`${collection.slug.current}`} >
            <button className='cursor-pointer transition-all duration-200 hover:scale-105 h-16 bg-[#facf38] w-full text-Black rounded-full mt-2 font-bold disabled:bg-gray-400'>Mint</button>
            </Link>
            </div>
            </div>
            
          ))}
        </div>
      </main>
    </div>


  )
}

export default Home

export const  GetServerSideProps = async () => {
  const query = `*[_type == "collection"]{
    _id,
      title,
      address,
      description,
      nftCollectionName,
      mainImage{
      asset
      },
    previewImage {
      asset
    },
    slug {
      current
    },
    creator -> {
      _id,
      name,
      address,
      slug{
        current
      },
    },
  }`

  const collections = await sanityClient.fetch(query)

  return{
    props: {
      collections
    }
  }
  
}


enter image description here

My Backend File // typings.d.ts

interface Image{
    asset: {
        url: string
    }
}

export interface Creator {
    _id:string
    name:string
    address:string
    slug:{
        current:string
    }
    image:Image
    bio:string
}

export interface Collection {
    _id:string
    title:string
    description:string
    nftCollectionName:string
    address:string
    slug:{
        current:string
    }
    creator:Creator
    mainImage:Image
    previewImage:Image
}

Everything is working in my local environment without any issues. However, when I try to deploy the project on Vercel by running 'npm run build', it encounters multiple errors and exits with code 1. I have attempted to remove node modules and reinstall packages, but the issue persists. Any assistance would be greatly appreciated.

I am trying to successfully deploy my project on a hosting platform like Vercel. While the code functions flawlessly locally, deployment is met with errors that prevent successful hosting. Your help in resolving these errors would be invaluable to me.

Answer №1

When utilizing GetServerSideProps
, remember that it should be structured as getServerSideProps

Ensure your function is constructed in the following format:

export const getServerSideProps: GetServerSideProps = async (context) => {
  // ...
}

For more information, refer to the typescript docs here

PS. It can be a bit confusing at first, but with practice, it becomes clearer.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Using boolean value as default input value in React

When trying to set the default value of a controlled checkbox input from my request, I encountered an error stating "Type 'boolean' is not assignable to type 'string | number | readonly string[] | undefined'". Do you have any suggestion ...

Eliminating null values from a multidimensional array

Is there a way to remove the array elements cctype, cctypologycode, and amount if they are empty? What would be the most efficient approach? { "ccInput": [ { "designSummaryId": 6, "CCType": "A", "CCTypologyCode": "A", "Amount ...

Update the header background color of an AG-Grid when the grid is ready using TypeScript

Currently working with Angular 6. I have integrated ag-grid into a component and I am looking to modify the background color of the grid header using component CSS or through gridready columnapi/rowapi. I want to avoid inheriting and creating a custom He ...

How can I emphasize the React Material UI TextField "Cell" within a React Material UI Table?

Currently, I am working on a project using React Material UI along with TypeScript. In one part of the application, there is a Material UI Table that includes a column of Material TextFields in each row. The goal is to highlight the entire table cell when ...

Customize the appearance of the Material UI expansion panel when it is in its expanded

Is there a way to customize the height of an expanded expansion panel summary? Specifically, I am looking to remove the min-height property and set the summary panel's height to 40px instead of the default 64px. I have attempted to make this change in ...

Learn how to easily set a background image using Tailwind CSS in a Next.js application

Trying to insert a background image into a section, but encountering an unexpected error. Here is the code I am using: The error message says: What steps should I take to resolve this issue? Even after removing the code, the error persists. ...

Retrieving Data from Angular Component within a Directive

Currently, I am in the process of creating an "autocomplete" directive for a project. The aim is to have the directive query the API and present a list of results for selection. A component with a modal containing a simple input box has been set up. The ob ...

The Next.js application is experiencing difficulties in loading scripts

I created a flawless Next.js application on my local machine. When I deployed it on AWS and tried to access it through my ALB, I encountered some errors in the console. Despite running "yarn run build" and "yarn run start" locally with success, the same di ...

I'm encountering a 502 error while trying to use Supabase's signInWIthPassword feature

Despite all authentication functions working smoothly in my React, TypeScript, and Supabase setup, I'm facing an issue with signInWithPassword. In my context: I can successfully signIn, create a profile, and perform other operations like getUser() an ...

What could be the reason behind the error message "Unable to locate module napi-v3/bcrypt_lib.node" when importing bcrypt?

When deploying on Vercel.com using Next.js /api routes which are AWS Lambdas under the hood, I encounter a server-side runtime import error with the Javascript bcrypt package: 41f80 ERROR Error: Cannot find module '/var/task/node_modules/bcrypt/li ...

Error message: "Supabase connection is returning an undefined value

I am encountering an issue with my Vercel deployed Remix project that utilizes Supabase on the backend, Postgresql, and Prisma as the ORM. Despite setting up connection pooling and a direct connection to Supabase, I keep receiving the following error whene ...

Tips for implementing self-managed state in Vue.js data object

My approach in organizing my Vue application involves using classes to encapsulate data, manage their own state (edited, deleted, etc), and synchronize with the back-end system. However, this method seems to conflict with Vue in some respects. To illustra ...

Angular 5 Image Upload - Transfer your images with ease

I am having trouble saving a simple post in firebase, especially with the image included. This is my current service implementation: uploadAndSave(item: any) { let post = { $key: item.key, title: item.title, description: item.description, url: '&a ...

Error: Unable to locate the specified Typescript function

For the source code, please visit https://github.com/zevrant/screeps I am encountering an issue with my implementation of interfaces in TypeScript. When trying to call the implemented interface, I am getting the following error: "TypeError: spawn.memory.t ...

Terser is causing ng build --prod to fail

When I run ng build --prod on my Angular 7 application (which includes a C# app on the BE), I encounter the following error: ERROR in scripts.db02b1660e4ae815041b.js from Terser Unexpected token: keyword (var) [scripts.db02b1660e4ae815041b.js:5,8] It see ...

Creating a variable as a list of string arrays in TypeScript

Currently working with Angular 2.0, I am trying to declare a variable in a Typescript file that is a list of string arrays. I attempted using yAxis_val: list, but it is not functioning correctly. If anyone knows the proper way to achieve this, please prov ...

Steps for implementing an EsLint Constraint specifically for next/link

How can I set up a linting rule to display an error if the next/link component is used for routing? I want to restrict routing to only be allowed through the default method. To resolve this issue, I included the statement "@next/next/no-html-link-for-pag ...

Error caused by properties of a variable derived from an interface in the compiler

I'm confused as to why the compiler is saying that the properties "name" and "surname" don't exist on type "ITest1" within function test1. It's a bit unclear to me: interface ITest1{ name: string; surname: string; age: number; } ...

Module not found

Hey everyone, I recently updated my project to node version v14.18.0, but now I'm encountering a "module not found" issue (see screenshot below). Any suggestions on how to resolve this? https://i.stack.imgur.com/k0u82.png ...

Struggling with establishing connection logic between two database tables using Prisma and JavaScript

I'm facing a perplexing logic problem that is eluding my understanding. Within the context of using next-connect, I have a function designed to update an entry in the database: .put(async (req, res) => { const data = req.body; const { dob ...