Issue with NextJS callback URL redirecting to another page is not occurring

When attempting to access a /Dashboard page after logging in through Gmail or GitHub on the client side using callbackUrl, I am encountering a 404 error stating that the page could not be found.

The project directory structure for the relevant files is as follows: pages.tsx renders the buttons.tsx buttons.

ProjectName
  /app
     pages.tsx
     /components
        buttons.tsx
  /pages
     dashboard.tsx

Below is the code for the sign-in button located in the buttons.tsx file:

return <button className="btn btn-secondary" onClick={() => signIn('google', { callbackUrl: '/Dashboard' })}>Sign in</button>;;

And here is the dashboard.tsx code:

import './Dashboard.css'
import DashBoardNavbar from "../components/DashboardNavbar"

interface Props {
    children: any
}

export default function Dashboard(props: Props) {

    return (
        <div>
            <div className="navbar-container"> 
                <DashBoardNavbar title="Medical Reports" description="View your medical reports"></DashBoardNavbar>
                <DashBoardNavbar title="Prescriptions" description="View your past and current prescriptions"></DashBoardNavbar>
                <DashBoardNavbar title="Appointments" description="View your past and future appointments"></DashBoardNavbar>
            </div>
        </div>

    )
}

I have attempted changing the provider (Google, undefined, etc.) but this did not resolve the issue. Is there something I might be overlooking?

Answer №1

To organize your files effectively, create a new folder inside the App directory called "dashboard" and then create a file named page.tsx within it.

  /app
     /dashboard
         page.tsx
     pages.tsx
     /components
        buttons.tsx

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

Seamless integration of NextJS with Woocommerce backend

I am currently in the process of integrating NextJS with a backend WooCommerce using GraphQL. One thing that I have been pondering is how to reconfigure the setup. Currently, Wordpress/WooCommerce is set up as follows: mywebwoo.com - default WordPress sto ...

What is the process of accessing information from a customer's form in a server section via the POST approach?

//Here is my client component located in Form/page.tsx "use client" import { useState } from 'react'; export default function Form() { const [name, setName] = useState('') const handleSubmit = async () => { try ...

The Discord Oauth2 API query parameter is returning as empty

While integrating Discord OAuth2 into my Next.js application, I encountered an issue when deploying to Amplify. The functionality works smoothly on localhost but fails in production. On the profile page, there is a setup for users to link their Discord acc ...

The NextJS error message states that the response payload size has exceeded the maximum allowed size limit of 6291556 bytes

Whenever I try to access the page where my API request response is displayed, I encounter an issue related to the size of the payload. The error message I receive is: { "errorMessage": "Response payload size exceeded maximum allowed payload ...

Decoding the build ID in NextJS: A step-by-step guide

When working with NextJS, there's the option to generate a build ID as mentioned in the documentation here: https://nextjs.org/docs/app/api-reference/next-config-js/generateBuildId Alternatively, it is also possible to retrieve the build ID based on ...

The error message "TypeError: (0 , _reduxjs_toolkit__WEBPACK_IMPORTED_MODULE_0__.createAsyncThunk) is not a function" indicates that

I encountered this unexpected error while attempting to deploy my client to Vercel. Utilizing NextJS, I am fetching data server-side with getStaticProps. Despite reinstalling the toolkit, the issue persists. import { createSlice, createAsyncThunk } from ...

The Next.js Image component is not compatible with an external URL as the image source

I've been struggling to use the image component in Next.js with an external URL as the source, but I keep encountering an error. I followed the instructions in the official Next.js documentation and updated the next.config.js file, but unfortunately, ...

Issue: Unable to locate ClerkInstanceContext - Encountered this error during the development of a project using the "nextjs

Currently, I am creating a replica of a threads app by following tutorials from the JS Mastery YouTube channel. However, I encountered an issue with the error message: ClerkInstanceContext not found. I attempted to resolve this by restarting the applicati ...

Setting up a middleware file for your nextJs project: A step-by-step guide

Currently, I am deep into a project that involves using Next.js. Progress has been steady so far, but there's a hitch with my middleware.ts file. Despite diligently following the Middleware documentation, it seems like the middleware is not triggering ...

Encountering a 504 Timeout Error with Next.js and Next-Auth on our live server

After successfully developing a basic Next.js app with authentication using Next-Auth, I encountered a peculiar issue upon deployment to my production server. Despite configuring the environment variables accordingly in the .env.local file, I faced a persi ...

Exploring dynamic page creation with Nextjs, utilizing Contentful for data management and implementing

My goal is to generate dynamic pages by clicking on tags within an article or elsewhere on my website. I am utilizing Next.js, SSG, and fetching articles with specific tags from Contentful using GraphQL queries: export async function getArticles() { con ...

Encountering the issue of "unresolved peer dependency error in Next.js" while trying to set up a Next.js application

Whenever I attempt to create a fresh Next.js application using the npx create-next-app@latest todo-app command, an error occurs during the installation process: "eslint-config-next > @typescript-eslint/parser > @typescript-eslint/typescript-es ...

the next development and build process becomes frozen indefinitely

Each time I try to execute pnpm dev, it seems to hang at ready - started server on 0.0.0.0:3000, url: http://localhost:3000 without displaying any errors. However, the server does not actually start at localhost:3000 because the page doesn't load when ...

Changing states in next.js is not accomplished by using setState

Struggling to update the page number using setCurrentPage(page) - clicking the button doesn't trigger any state change. Tried various methods without success. Manually modified the number in useState(1) and confirmed that the page did switch. import ...

Deploy your Next JS project using the ASP.NET Core Visual Studio React template

After deciding to enhance my project that began with the asp.net core react template in Visual Studio by adding SSR capability with Next.js, I encountered an issue. Previously, when clicking on the run project button in Visual Studio, both the API server a ...

Error message: Nextjs encounters hydration issue only in the production environment

I've been facing this issue for hours now. I deployed my Next.js application on Vercel and encountered numerous hydration errors there. Interestingly, in my local development environment, I don't experience any errors at all. I came across sugge ...

Simulating server-side interactions in Node.js with TestCafe

I am currently working on a project where I need to figure out how to mock server-side requests. While I have successfully managed to mock client-side requests using request hooks, I am facing challenges when it comes to intercepting server-side requests ...

What causes the index to display [object Object] rather than an integer in React?

It has been a long time since I last worked with React, and now I'm facing an issue. Whenever I use console.log to display the index within the map function, my console output looks like this: https://i.stack.imgur.com/VbGmE.png However, the result ...

What is the most effective way to bring in "server-side only" code in Next.js?

I am currently working on my index page's getServerSideProps function and I want to utilize a function called foo, which is imported from another local file. This function relies on a specific Node library that cannot be executed in the browser becaus ...

What is the best way to manage user sessions for the Logout button in Next.js, ensuring it is rendered correctly within the Navbar components?

I have successfully implemented these AuthButtons on both the server and client sides: Client 'use client'; import { Session, createClientComponentClient } from '@supabase/auth-helpers-nextjs'; import Link from 'next/link'; ...