TypeError: e is undefined
Answered
aprilia posted this in #help-forum
69 Replies
apriliaOP
@DeFc0n
import { NextResponse } from 'next/server'
import type { NextRequest } from 'next/server'
export function middleware(request: NextRequest) {
const requestHeaders = new Headers(request.headers)
requestHeaders.set('x-pathname', request.nextUrl.pathname)
const response = NextResponse.next({
request: {
// New request headers
headers: requestHeaders,
},
})
return response
}
export const config = {
matcher: [
/*
* Match all request paths except for the ones starting with:
* - api (API routes)
* - _next/static (static files)
* - _next/image (image optimization files)
* - favicon.ico (favicon file)
*/
'/((?!api|_next/static|_next/image|favicon.ico).*)',
],
}
this is the most recent change i have made
okay show me the console in vs code
apriliaOP
keep the console open and refresh
apriliaOP
I did refresh but i dont see any new logs in the terminal
apriliaOP
its fixed?
apriliaOP
no
like i said in local machine i dont see any error
only after deploying to vercel i see the error and the error message aint helpful at all
in local machine it works but in vercel it shows the error?
apriliaOP
yes
forget local machine, show me vercel logs
apriliaOP
this is the most recent change
from this ^ i have added the middleware and changed it to
const pathname = headersList.get("next-url")
from this ^ i have added the middleware and changed it to
const pathname = headersList.get("x-pathname")
dont see anythink wrong in there
are there other logs, other then api logs
apriliaOP
no
try rebuild
apriliaOP
is there any way to get full error message in vercel ?
never used vercel for hosting so i cant really tell you,
try to rebuild the project
apriliaOP
yeah rebuilding
most likely wont fix it ill do some digging
apriliaOP
https://github.com/coding-club-gct/blogs
repo if you would like to see 🙂
repo if you would like to see 🙂
rebuild completed, verfied it in private window still the same issue
damn :(
i know its frosturating but dont give up, eventually you will fix it
apriliaOP
yeah, i have to do some really annoying if statements and deploy each time
in your local machine, try this
npm run build npm run start
npm run build npm run start
apriliaOP
i think i can do this, but its frustrating :(
and see if the error happens there
as this error happens in production, not development, you run npm run build to build the production files, then npm run start
apriliaOP
yeah like i said production mode in local machine works fine
no error
thats odd
TypeError: Cannot destructure property 'auth' of 'e' as it is undefined.
i got this error
apriliaOP
check where you have perfomed
.auth
this error happens when trayng to access a null object
in your case e is undefined
i navigate to how to blog
apriliaOP
oh
btw hello ray, hope you had a nice day
const { name, blog, html_url, email } = await getProfileFromUsername(author.login)
const { name: committerName } = await getProfileFromUsername(committer.login)
i think the error come from here
apriliaOP
yeah i can see the error message in chrome as well
damn firefox and chrome giving different error messages
you too 😀
my day was mid, could for the love of me, not get data revalidation to work
revalidation something is a little bit tricky for now 😆
then i tried router.reload
guess what it didnt work
if i had to track the time i spend, 99% is bug fixing
apriliaOP
apparently something is getting messed up with the
Link
componentapriliaOP
i have replaced all the
Link
with <></>
and now its workingwhat were you using link for?
apriliaOP
i get few urls from github api and print it in the page
with link tag
glad to be of help, even if it was 1%, mark this as solved
apriliaOP
yes, thank you as well
you're welcome
you can also close the post,