-2

I have a bug, i'm trying to make his tutorial for twitter clone in nextjs+tailwindcss+typescript

https://www.youtube.com/watch?v=rCselwxbUgA&t=1357s&ab_channel=SonnySangha 1:42:05 / 3:17:52

I did exactly the same but i feel like my IDE or my nextJS version is making things different

import { Tweet } from "../typings"

export const fetchTweets = async () => {
    const res = await fetch(`${process.env.NEXT_PUBLIC_BASE_URL}/api/getTweets/`)
    const data = await res.json();
    const tweets: Tweet[] = data.tweets;
    return tweets
}

FetchError: request to https://localhost:3000/api/getTweets/ failed, reason: write EPROTO 140020696905664:error:1408F10B:SSL routines:ssl3_get_record:wrong version number:../deps/openssl/openssl/ssl/record/ssl3_record.c:332:

This error happened while generating the page. Any console logs >will be displayed in the terminal window.

import { Tweet } from "../typings"  
  
export const fetchTweets = async () => {  
      
    if(global.window) {  
        const res = await 
        fetch(`${process.env.NEXT_PUBLIC_BASE_URL}/api/getTweets/`)  
        const data = await res.json();  
        const tweets: Tweet[] = data.tweets;  
        return tweets  
    }  
      
}

Server Error Error: Error serializing .tweets returned from getServerSideProps in "/". Reason: undefined cannot be serialized as JSON. Please use null or omit this value.

If someone can help me <3 thanks

Ethan
  • 881
  • 8
  • 14
  • 26
SashaBRRRR
  • 21
  • 4

1 Answers1

1

FIXED :

.env.local

i writed

NEXT_PUBLIC_BASE_URL=https://localhost:3000/

change https:// by http:// and yarn run dev again


NEXT_PUBLIC_BASE_URL=http://localhost:3000/

SashaBRRRR
  • 21
  • 4