Render Correct HTML From Markdown Input (Left / Right Side Of Eachother)

The goal here is to create a minimalistic MD editor which will save the *.md file to a pre defined directory when the “save” button is clicked/ pressed.

In other words, like this:

Two textareas. Both are initially blank. When typing markdown formatted text into the left side textarea, the markdown is converted into HTML and displayed within the right textarea.

As of now, it works in terms of text being displayed in the right area (the HTML area), but it is not formatted as HTML (it is not being converted).

Examples:

# Hello World! = <h1>Hello World!</h1>

**Cool** = <b>Cool</b> (or strong)

Basically, nothing is converted / parsed into HTML and it does not add line breaks, new rows – NOTHING.

My question is, where am I going wrong here?
I need to be able to see the HTML version on the right as I type on the left.

Hopefully, the image explains it better.

The code I am working on:

<?php
if ( $_SERVER["REQUEST_METHOD"] == "POST" ) {
    $content = $_POST['content'];
    $file_name = 'article.md';
    $file_path = __DIR__ . '/' . $file_name;
    if ( file_put_contents( $file_path, $content ) ) {
        $message = 'File saved successfully.';
    } else {
        $message = 'File could not be saved.';
    }
}
?>
<!DOCTYPE html>
<html lang="sv">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>md Editor</title>
    <style>
        body {
            font-family: Arial, sans-serif;
            background-color: #f4f4f4;
            margin: 0;
            padding: 0;
        }

        .container {
            max-width: 800px;
            margin: 20px auto;
            padding: 20px;
            background-color: #fff;
            border-radius: 5px;
            box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
        }

        h1 {
            margin-top: 0;
        }

        .editor {
            display: flex;
        }

        textarea {
            width: 50%;
            height: 500px;
            resize: none;
            padding: 10px;
            border: 1px solid #ccc;
            border-radius: 5px 0 0 5px;
        }

        #preview {
            width: 50%;
            padding: 10px;
            border: 1px solid #ccc;
            border-radius: 0 5px 5px 0;
            background-color: #f9f9f9;
            overflow-y: auto;
        }

        button {
            margin-top: 10px;
            padding: 10px 20px;
            background-color: #007bff;
            color: #fff;
            border: none;
            border-radius: 5px;
            cursor: pointer;
        }

        button:hover {
            background-color: #0056b3;
        }
    </style>
</head>
<body>

<div class="container">
    <h1>md Editor</h1>

    <div class="editor">
        <textarea id="mdtext" placeholder="Start writing your article here using Markdown.." oninput="updatePreview()"><?php echo isset($_POST['content']) ? $_POST['content'] : ''; ?></textarea>
        <div id="preview"></div>
    </div>

    <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
        <input type="hidden" name="content" id="content">
        <button type="submit">Save md Article</button>
    </form>

    <?php if(isset($message)): ?>
        <script>alert('<?php echo $message; ?>');</script>
    <?php endif; ?>
</div>

<script src="https://cdn.jsdelivr.net/npm/marked/marked.min.js"></script>
<script>
    function updatePreview() {
        var markdownInput = document.getElementById('mdtext').value;
        var preview = document.getElementById('preview');
        preview.innerHTML = markdownInput;
        document.getElementById('content').value = markdownInput;
    }
    document.getElementById('mdtext').addEventListener('input', updatePreview);
    updatePreview();
</script>

</body>
</html>

enter image description here

Any ideas on how to fix this? I’m feeling completely lost at the moment.

How to send a state variable of a component to the url of another page? (ReactJS)

//Navbar.jsx

const [query, setQuery] = useState("")
const handleChange = (e) => {
setQuery(e.target.value) }
.
.
.
<input value={query} id="query" onChange={handleChange} />

Now my question is, I have a separate route (“/search/:query”, component is Search.jsx). How do I send the ‘query’ state from the navbar to this route so that I can extract the query from the params and use it afterwards?

Basically it’s a movie site and I have a search bar at the home page (in navbar) and a separate page for searching too but I want the search parameter in home page/navbar to be sent to that search page route for params extraction

I thought of prop sending but that wouldn’t work since I’m sending data to the params of the url, so I’m pretty clueless

I am using react-router

In my p5.js sketch, why does the input element behave strangely on android (mobile) chrome and Firefox?

I have a p5 sketch which is a small eye-spy game. It includes a leaderboard where the user can input their name. When I test on android mobile browsers(chrome and Firefox), this input behaves strangely. For example, upon clicking the input, the keyboard appears but a user can not type at all. Or alternatively, upon clicking the input, the keyboard will appear but the cursor does not appear in the input box unless the user taps it again, in which case they can type, but sometimes letters will be dropped, and upon submitting, the value of the input box is undefined, null or empty.

Other issues also appear after the user submits using the button below the input, namely the input box and button do not disappear, and as I said the leaderboard does not display the name which the player input as the value of the input element was undefined.

None of these problems appear in mobile safari or on desktop browsers, as far as I can tell.

The code to the project is here: https://github.com/bee-mcc/SpyDay

You can test the project here: https://spyday.nochillzone.games

I tried reducing the scope of the project dramatically, so that the sketch was literally just a text box centered on the screen, and as expected this did not present any problem on Firefox android mobile browser. Therefore, as expected, the problem should be with my code.

beginner with a problem in responsive sites

enter image description here
I NEED HELP! I am new in development and trying responsive sites and when I use the toggle devices toggle it doesnt hide the links it just kinda expands the page, please refer to the image for a better description of what im referring to.

P.S I was just practicing, I apologize for the bad layout 🙂

Here is the code:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link rel="stylesheet" href="style.css">
    <title>Document</title>
</head>
<body>

    <nav>
        <div class="logo">
            <h4>Wew</h4>
        </div>
        <ul class="links">
            <li><a href=""></a>hehehh</li>
            <li><a href=""></a>hehehh</li>
            <li><a href=""></a>hehehh</li>
            <li><a href=""></a>hehehh</li>
        </ul>
        <div class="burger">
            <div class="line1"></div>
            <div class="line2"></div>
            <div class="line3"></div>
        </div>
    </nav>
    
    <script src="index.js"></script>
</body>
</html>
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}
html{
    width: 100%;
    overflow-x: hidden;
  }
nav {
    align-items: center;
    background-color: red;
    display: flex;
    padding: 0 5rem;
    justify-content: space-between;
    height: 90px;
}
nav ul {
    display: flex;
    gap: 40px;
}
nav li {
    list-style: none;
}
.burger div {
    width: 25px;
    height: 3px;
    margin: 4px;
    background-color: black;
}
.burger {
    display: none;
}

@media screen and (max-width: 940px) {
    body {
        overflow-x: hidden;
    }
    .burger {
        display: block;
    }
    .links {
        position: absolute;
        right: -100%;
        top: 5.6rem;
        height: 300px;
        width: 200px;
        flex-direction: column;
        background-color: red;
        transition: all 0.50s ease;
    }
    .links li {
        position: relative;
        left: 30px;
        width: 100px;
        top: 20px;
    }
    .burger {
        z-index: 1;
    }
}

.nav-active {
    right: 0%;
}
const Navslide = () => {
    const burger = document.querySelector(".burger")
    const links = document.querySelector(".links")

    burger.addEventListener("click", () => {
        links.classList.toggle("nav-active")
    })
}

Navslide()

Get the Coordinate of Original Image

I need to customize my image with CSS and I plan to dot 2 point and get the coordinate of image base on original size of image and the we can dot over the image only(Note: the coordinate not base the size that i custom with CSS or on screen).

import React, { useState } from 'react';
import src from "../assets/testCoordinate.jpeg";
import ReactPlayer from 'react-player'
import Select from "react-select"
const ImageDetection = () => {
    const [isSelecting, setIsSelecting] = useState(false);
    const [startX, setStartX] = useState(null);
    const [startY, setStartY] = useState(null);
    const [endX, setEndX] = useState(null);
    const [endY, setEndY] = useState(null);
    const [imageWidth, setImageWidth] = useState(null);
    const [imageHeight, setImageHeight] = useState(null);

    const handleClick = (event) => {
        const { offsetX, offsetY } = event.nativeEvent;
        const { width, height } = event.currentTarget.getBoundingClientRect();
      

        if (isSelecting) {
            setEndX(offsetX);
            setEndY(offsetY);
            setIsSelecting(false);
            console.log(`End clicked at: (${offsetX}, ${offsetY})`);
        } else {
            setStartX(offsetX);
            setStartY(offsetY);
            setIsSelecting(true);
            console.log(`Start clicked at: (${offsetX}, ${offsetY})`);
        }
    };

    const startMarkerStyle = {
        position: 'absolute',
        left: `${startX}px`,
        top: `${startY}px`,
        width: '10px',
        height: '10px',
        backgroundColor: 'green',
        borderRadius: '50%',
    };

    const endMarkerStyle = {
        position: 'absolute',
        left: `${endX}px`,
        top: `${endY}px`,
        width: '10px',
        height: '10px',
        backgroundColor: 'red',
        borderRadius: '50%',
    };

    const lineStyle = {
        position: 'absolute',
        zIndex: 1,
        left: 0,
        top: 0,
        width: '100%',
        height: '100%',
    };

    const handleImageLoad = (event) => {
        const { naturalWidth, naturalHeight } = event.target;
        setImageWidth(naturalWidth);
        setImageHeight(naturalHeight);
    };

    return (
        <div style={{ position: 'relative', }} >
            {/* <h1>Set the Strict Line</h1>
            <Select
            className='w-[240px] h-[60px]'
                options={[
                    { value: 'video', label: 'Video' },
                    { value: 'image', label: 'Image' }
                ]}
            /> */}

            <img
                src={src}
                alt="Test Image"
                onClick={handleClick}
                className='w-[740px] h-[540px]'
                onLoad={handleImageLoad}
            />
            {/* <ReactPlayer url='https://buyme-now-bucket.s3.ap-southeast-2.amazonaws.com/huh.mp4' /> */}
            {startX !== null && (
                <div style={startMarkerStyle}>
                    {/* Start point marker */}
                </div>
            )}
            {endX !== null && (
                <div style={endMarkerStyle}>
                    {/* End point marker */}
                </div>
            )}
            {startX !== null && endX !== null && (
                <svg style={lineStyle}>
                    <line x1={startX} y1={startY} x2={endX} y2={endY} stroke="blue" strokeWidth="2" />
                </svg>
            )}
            {imageWidth && imageHeight && (
                <p>Image Original Size: {imageWidth} x {imageHeight}</p>
            )}
        </div>
    );
};

export default ImageDetection;

I want a Point of image base on its original width and Height

MongooseJS find if in array

I have a foreign key field in an array:

const passageSchema = mongoose.Schema({
    input: [{
        type: mongoose.Schema.Types.ObjectId,
        ref: 'Passage'
    }],
});

And I have a passage:

var passage = Passage.findOne({_id: passageID});

And I want to find all passages that have this passage as an input.

var passages = Passage.find({
        //find if in array
        input: passage //would work if it wasn't an array in schema
 });

Static files such as CSS and images are not loading in the Laravel project on an EC2 instance server

This is my folder structure. I have uploaded a Laravel project on an EC2 instance. The static files such as CSS and images are not loading. I got 404 error in that static files location.but files are in that location.

/project
       /app
       /bootstrap
       /public
          /frontend
             /common
               /css
                 main.css
                 main-rtl.css
          index.php

      

this is nginx setup.Is there anything to add in nginx setup.

server {
        listen   80;
        root /home/ubuntu/websites/farmersdirect.lk/public_html/public;
        index index.html index.htm index.php;
        server_name dev.farmersdirect.lk test.ersdirect.lk;
        error_log /home/ubuntu/websites/farmersdirect.lk/logs/error.log;
   
    location ~ .php$ {
            try_files $uri /index.php =404;
            fastcgi_split_path_info ^(.+.php)(/.+)$;
            fastcgi_pass unix:/run/php/php8.2-fpm.sock;
            fastcgi_index index.php;
            fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
            include fastcgi_params;
        }

    location = /favicon.ico { access_log off; log_not_found off; }
        location = /robots.txt  { access_log off; log_not_found off; }

        location / {
                    proxy_pass http://127.0.0.1:8000;
                    proxy_http_version 1.1;
                    proxy_set_header Upgrade $http_upgrade;
                    proxy_set_header Connection 'upgrade';
                    proxy_set_header Host $host;
                    proxy_cache_bypass $http_upgrade;
            try_files $uri $uri/ /index.php?$query_string;
        }

    #add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
    add_header X-XSS-Protection "1; mode=block";
    add_header X-Content-Type-Options nosniff;
    #add_header Strict-Transport-Security 'max-age=31536000; includeSubDomains; preload';
    add_header X-Frame-Options "SAMEORIGIN";
    #add_header Content-Security-Policy "frame-ancestors 'self';";
        
    location ~ /.(?!well-known).* { deny all; access_log off; log_not_found off; }

    location ~* /(?:uploads|files|wp-content|wp-includes|akismet)/.*.php$ {
        deny all;
        access_log off;
        log_not_found off;
    }
}

       

What is the issue with the CSS and images not loading?

Server Side Component return type when it is async in NextJS 14

In NextJS 14, the example given in the docs is within the Page component, which I usually type as NextPage. This type doesn’t accept async await server component.

Similarly, what I tend to do is to wrap my own component and I always typed them as FunctionComponent<MyProps>. This also doesn’t work on async await server component that is given in the example.

What should the type be in this case instead of FunctionComponent / NextPage?

// FunctionComponent doesn't work here, TS error:  
// Type 'Promise<Element>' is missing the following properties from type 'ReactElement<any, any>': type, props, keyts(2322)
export const Header: FunctionComponent<HeaderProps> = async ({
  handleSidebarOpen,
}) => {
  const user = useUserSession();
  const userCredit = await getCredit(user.id);

Another example for NextPage:

// FunctionComponent doesn't work here, TS error:  
// Type '() => Promise<JSX.Element>' is not assignable to type 'FunctionComponent<{}>'.
export const MyPage: NextPage = async ({}) => {
  const userCredit = await getCredit(user.id);

Trying to create a “copy” button for my website, isn’t working

`Backstory: I’m making a simple bibliography website and am struggling on the copy button. Even after using clipboardjs, the copy feature of the button isn’t working.

I got so desperate to where I asked ChatGPT, and no matter what they suggest, I come up with the same result: it doesn’t work! I was hoping someone on this website could help me. I will include my HTML, CSS, and JS below.

'use strict';

document.addEventListener('DOMContentLoaded', function () {
    var leftTextbox = document.getElementById('leftTextbox');
    var inputTextArea = document.getElementById('inputTextArea');
    var citationTextArea = document.querySelector('#rightTextbox textarea');
    var copyButton = document.getElementById('copyButton'); // Add copy button reference

    leftTextbox.addEventListener('click', function () {
        this.classList.toggle('active');
    });

    inputTextArea.addEventListener('input', function () {
        this.style.height = 'auto';
        this.style.height = (this.scrollHeight) + 'px';
    });

    inputTextArea.addEventListener('keydown', function (event) {
        if (event.key === 'Enter' && !event.shiftKey) {
            event.preventDefault();
            citationTextArea.value += this.value + 'n';
            this.value = '';
            this.style.height = 'auto';
            this.style.height = (this.scrollHeight) + 'px';
        }
    });

    var clearButton = document.getElementById('clearButton');

    clearButton.addEventListener('click', function () {
        citationTextArea.value = '';
    });

    // Initialize Clipboard.js
    var clipboard = new ClipboardJS(copyButton, {
        text: function() {
            return citationTextArea.value;
        }
    });

    // Update success and error handling
    clipboard.on('success', function(e) {
        console.log('Text copied to clipboard:', e.text);
    });

    clipboard.on('error', function(e) {
        console.error('Failed to copy text:', e.action);
    });
});
/* style.css */

body {
    font-family: Arial, sans-serif;
    margin: 0;
    padding: 0;
    background-color: #f2f2f2;
    display: flex;
    flex-direction: column;
    height: 100vh;
}

header {
    background-color: #333;
    color: #fff;
    padding: 20px 0;
    text-align: center;
}

main {
    flex: 1; /* Allow main to take up remaining vertical space */
    display: flex;
    justify-content: space-around;
    align-items: stretch;
    padding: 20px;
}

.textbox {
    width: 45%;
    background-color: #fff;
    display: flex;
    flex-direction: column;
    border: 2px solid #ddd; /* Set border width to 2px */
    border-radius: 5px;
    padding: 10px;
    transition: border-color 0.3s; /* Add transition effect for border color */
    position: relative; /* Add relative positioning */
}

.textbox.active {
    border-color: black;
    border-width: 2px; /* Increase border width for active state */
}

.textbox h2 {
    margin-top: 0;
}

.textbox-content {
    flex: 1; /* Allow textarea to take up remaining vertical space */
    width: calc(100% - 20px); /* Adjust width for padding */
    height: calc(100vh - 100px); /* Set height to fill remaining viewport height */
    resize: none;
    border: none;
    outline: none;
    background-color: transparent; /* Set transparent background color for text area */
    font-size: 16px;
    line-height: 1.5;
    overflow-y: auto; /* Add scrollbar when necessary */
}

/* Add styles for the clear button container */
.textbox-action-buttons {
    display: flex;
    align-items: center;
    margin-bottom: 10px; /* Add margin at the bottom */
}

/* Add styles for the clear button */
#clearButton,
#copyButton {
    width: 30px; /* Set width of the button */
    height: 30px; /* Set height of the button */
    border: none;
    background-color: #ccc;
    color: #333;
    font-size: 20px; /* Increase font size for the symbol */
    line-height: 1;
    cursor: pointer;
    margin-right: 5px; /* Add some spacing between the buttons */
}

#clearButton:hover,
#copyButton:hover {
    background-color: #999;
    color: #fff;
}

#clearButton {
    position: absolute;
    top: 10px;
    right: 5px;
}

#copyButton {
    position: absolute;
    top: 10px;
    right: 50px
}
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Bibby.io</title>
    <link rel="stylesheet" href="style.css">
</head>
<body>

<header>
    <h1>Bibby.io</h1>
    <h2>Easy Use MLA Formatting</h2>
</header>

<main>
    <div class="textbox" id="leftTextbox">
        <h2>Input</h2>
        <textarea id="inputTextArea" class="textbox-content" placeholder="Enter text here..."></textarea>
    </div>

    <div class="textbox" id="rightTextbox">
        <h2>Works Cited</h2>
        <div class="textbox-action-buttons">
            <button id="copyButton">&#x2398;</button> <!-- Copy button -->
            <button id="clearButton">&#10006;</button> <!-- Delete button -->
        </div>
        <textarea id="citationTextArea" class="textbox-content" placeholder="" disabled></textarea>
    </div>
</main>

<script src="https://cdnjs.cloudflare.com/ajax/libs/clipboard.js/2.0.8/clipboard.min.js"></script>
<script src="script.js" defer></script> <!-- Include the JavaScript file here with defer attribute -->

</body>
</html>

I feel like I tried everything.

How update change network ID in MetaMask after change network on MetaMask?

What I am trying to do is to change the network from the select list. Then AlpineJS should send a request to MetaMask to switch the network, and this works perfectly. I can detect when the user changes the network on MetaMask, and I can refresh the website, etc. This is my code:

function formTag() {
    return {
      selectedNetwork: null,
       networks: {!! $networks !!},
       changeNetwork() {
       if (!this.selectedNetwork) {
         return;
      }
       if (window.ethereum) {
       window.ethereum.request({
       method: 'wallet_switchEthereumChain',
       params: [{ chainId: this.selectedNetwork }],
      })
      .then((response) => {})
      .catch((error) => {
       console.error('Error while switching networks:', error);
      });
      } else {
       console.error('MetaMask not installed');
      }
      },
       async getNetworkId() {
       try {
       if (!window.ethereum) {
       alert('MetaMask not detected. Please try again from a MetaMask enabled browser.');
       return;
      }
       const web3 = new Web3(window.ethereum);
       this.selectedNetwork = await window.ethereum.request({ method: "eth_chainId" });
console.log(await window.ethereum.request({ method: "eth_chainId" }));
      } catch (error) {
       console.error("Error:", error);
      }
      },
       init() {
       this.getNetworkId();
       window.ethereum.on('chainChanged', (chainId) => {
      /*window.ethereum.request({
       method: 'wallet_switchEthereumChain',
       params: [{ chainId: chainId }],
      })*/
       this.selectedNetwork = chainId;
      });
       window.ethereum.on('accountsChanged', function (accounts) {
       console.log(accounts[0]);
      });
    },
   }
 }

if i keep commented line below, after chnage network on MM i still see old chainID console.log(await window.ethereum.request({ method: "eth_chainId" }));

/*window.ethereum.request({
  method: 'wallet_switchEthereumChain',
  params: [{ chainId: chainId }],
})*/

But if I uncomment the line above, after changing the network in MetaMask, it closes and opens for a second (I think for updating the same network value), and console.log(await window.ethereum.request({ method: "eth_chainId" })); is okay. Why should I update MetaMask after changing the network on MetaMask? Or is other way?

How can i detect screen is recording in React Native

I’m doing an app that play music, I would like my music is private so i don’t want user can use screen record to record the screen or my music in React Native i have do this in MainActivity.java

getWindow().setFlags(WindowManager.LayoutParams.FLAG_SECURE, WindowManager.LayoutParams.FLAG_SECURE);

it make my screen go dark but user still record my music

How do I dynamically change nav link text color based on background brightness?

Admittedly not a developer, but trying to learn my way through customizing a Squarespace site for myself.

I was looking to implement some code that updates the color of my nav links based on the content that exists behind them at any given point as the user scrolls (or as the full-bleed hero carousel cycles between content). Background content could be anything really: light color blocks, dark color blocks, imagery, video, etc…

Open to any ways you feel would work! Not looking to simply use the ‘difference’ CSS property either fwiw, would prefer that the link text color cycles only between black and white.

Thanks in advance for your help!

I was trying to follow the suggested answer in this thread, but when I implement the code on my site it just keeps setting the background color on the element and then randomizes that color on a timer (to credit the poster, the text does change the way I’d like it to though!). Ideally I would be able to simply detect the background brightness of the nav items’ container, and then set the color of the nav link text accordingly, if that makes sense?

Why is Axios returning data as “undefined” from the API when using React using Vite?

I’m using Axios to fetch data related to movies as part of my project. However, when I execute console.log(response.data), it returns something in the form of an HTML document. When I visit the link directly, it yields data in JSON format. How do I fix this ?

1)The main code:

import { useEffect, useState } from 'react';
import './Banner.css' 
import requests from './Requests';
import axios from './Axios'

function Banner() {

    const [movie, setMovie] = useState([]);

    useEffect(() => {
        let fetchData = async () => {
            let response = await axios.get(requests.fetchPopular);
            console.log(response.data);

        }
        fetchData();
    }, []);`

2)Axios.jsx code:

import axios from "axios";

const instance = axios.create({
     baseURL: "​https://api.themoviedb.org/3"
});

export default instance`

Requests.jsx code:

const API_KEY = "**************************";
const requests = {
    fetchPopular: `​​/movie/popular?api_key=${API_KEY}`
};
export default requests;

Output of console.log(response.data):

<!doctype html>
<html lang="en">
  <head>
    <script type="module">
import RefreshRuntime from "/@react-refresh"
RefreshRuntime.injectIntoGlobalHook(window)
window.$RefreshReg$ = () => {}
window.$RefreshSig$ = () => (type) => type
window.__vite_plugin_react_preamble_installed__ = true
</script>

    <script type="module" src="/@vite/client"></script>

    <meta charset="UTF-8" />
    <link rel="icon" type="image/svg+xml" href="/vite.svg" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Vite + React</title>
  </head>
  <body>
    <div id="root"></div>
    <script type="module" src="/src/main.jsx?t=1709691322963"></script>
  </body>
</html>

I was trying to retrieve data using Axios in object form however, I’m receiving it as “undefined” even though when I visit the link directly, the API seems to be working.

signature in React Native

I am trying to use a signature input in React Native. After installing the library, the signature area refuses to appear. Even I’am using the same code as in the documentation, but nothing happens the signature area refuses to appear.enter image description hereenter image description here

Error occurred prerendering page while using component & SSR in pages in next js

I am getting this error while deploying my next js project in vercel.

Error occurred prerendering page "/bollywood". Read more: https://nextjs.org/docs/messages/prerender-error

I have this code in in the /bollywood/page.jsx file

import Hero from '@/components/Hero'
import Page_reuseable from '@/components/Page_reuseable'
import Subscribe from '@/components/Subscribe'
import React from 'react'

export default function Page() {
  return (
    <>
      <Hero link={'category/bollywood'} />
      <Page_reuseable category={"Bollywood"} />
      <Subscribe />
    </>
  )
}

and the Hero and Page_reuseable component has these code

//components/Hero.jsx


async function fetch_data(link) {
    const req = await fetch(`${process.env.NEXT_PUBLIC_DEVELOPMENT_BACKEND_URL}/${link}?limit=1`, { credentials: "include", headers: { "x-api-key": process.env.API_KEY }, cache: "no-cache" })
    const res = await req.json()
    if (res.status == 'success') {
        return res.posts[0]
    } else {
        return []
    }
}

export default async function Hero({ link }) {
    const data = await fetch_data(link)

    return (
        <>
          //jsx
        </>
    )
}



//component/Page_reuseable.jsx

async function fetchData(category, limit) {
    const req = await fetch(`${process.env.NEXT_PUBLIC_DEVELOPMENT_BACKEND_URL}/category/${category}?limit=${limit}`, { credentials: 'include', headers: { "x-api-key": process.env.API_KEY }, cache: "no-cache" })
    const res = await req.json()
    if (res.status === 'success') {
        return res.posts;
    } else {
        return [];
    }
}


export default async function Page_reuseable({ category }) {

    let limit = 11

    const data = await fetchData(category, limit)

    return (
        <>
              //jsx
        </>
    )
}

Now I don’t know what is the problem. I am using those component in other pages and it is giving the same error for every page while generating static page while deploying in vercel (working fine locally).

I provide the error log if needed below

Error: Unsupported Server Component type: {...}
    at em (/vercel/path0/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:12:131932)
    at /vercel/path0/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:12:142926
    at Array.toJSON (/vercel/path0/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:12:146504)
    at stringify (<anonymous>)
    at eR (/vercel/path0/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:12:134889)
    at eP (/vercel/path0/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:12:135332)
    at AsyncLocalStorage.run (node:async_hooks:338:14)
    at Timeout._onTimeout (/vercel/path0/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:12:146956)
    at listOnTimeout (node:internal/timers:569:17)
    at process.processTimers (node:internal/timers:512:7)
TypeError: i is not iterable
    at i (/vercel/path0/.next/server/chunks/231.js:1:6898)
    at o (/vercel/path0/.next/server/chunks/231.js:1:1213)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
TypeError: i is not iterable
    at i (/vercel/path0/.next/server/chunks/231.js:1:6898)
    at o (/vercel/path0/.next/server/chunks/231.js:1:1213)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
Error occurred prerendering page "/bollywood". Read more: https://nextjs.org/docs/messages/prerender-error
TypeError: i is not iterable
    at i (/vercel/path0/.next/server/chunks/231.js:1:6898)
    at o (/vercel/path0/.next/server/chunks/231.js:1:1213)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)

   Generating static pages (8/16) 
[]
[]
[]

// getting this error as well
TypeError: i is not iterable
    at i (/vercel/path0/.next/server/chunks/231.js:1:6898)
    at o (/vercel/path0/.next/server/chunks/231.js:1:1213)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
TypeError: i is not iterable
    at i (/vercel/path0/.next/server/chunks/231.js:1:6898)
    at o (/vercel/path0/.next/server/chunks/231.js:1:1213)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
Error occurred prerendering page "/dollywood". Read more: https://nextjs.org/docs/messages/prerender-error