How to toggle theme color in c# aspnet core with toggle button inside partalview?

Explaination

I want to toggle the bootstrap 5.3 theme color through a button inside a partalview.

The toggle button is customised on my specific needs and the value is saved inside a cookie, which i call when needed.

The partial view will be included in the navbar menu.

For some strange reason i can not manage to find a suitable solution, for this case.

Question

How can this be implemented, which is the correct way?

The partialview code

@{

static void ToggleTheme()
{
    string bg = HttpContext.Request?.Cookies["mybg"]?.ToString();

    if (bg == "light" || bg == null)
    {
        HttpContext.Response.Cookies.Delete("mybg");
        HttpContext.Response.Cookies.Append("mybg", "dark");
    }
    else
    {
        HttpContext.Response.Cookies.Delete("mybg");
        HttpContext.Response.Cookies.Append("mybg", "light");
    }
}

}

    <button type="submit" name="submit" class="btn btn-sm btn-outline-light" onclick="ToggleTheme()">

Theme

How can I send data from JavaScript to Python Streamlit using postMessage?

Parent Code ( VSCode Extension Webview Code )

    private renderHtml(): string {
    return `<!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="${this._chatStyle}">
              </head>
              <body>
                  <iframe id="chatView" src="${url}"></iframe>
                  <script type="module" src="${this._chatSrc}"></script>
              </body>
              <script>
                  window.param = ${param};
              </script>
       </html>`;
    } 

this._chatSrc ( ChatView.js )

    const vscode = acquireVsCodeApi();
    const iframe = document.getElementById('chatView');
    iframe.onload = () => {
      const iframeWindow = iframe.contentWindow;
      iframeWindow.postMessage(JSON.stringify(window.param, null, 2), '*');
    };

    const handleMessage = event => {
      console.log('Received message:', event.data);
    };

    window.addEventListener('message', handleMessage);

Child Code( Python Streamlit )

from openai import OpenAI
import streamlit as st
js = """
<script>
    window.addEventListener("message", (evt) => {
        console.log('call')    
    });
    window.parent.parent.postMessage("Some data", '*');
</script>
"""
st.components.v1.html(js, height=0)

When I use window.addEventListener
in Streamlit, it doesn’t seem to trigger. How can I receive data from the parent window in Streamlit using an event listener?

RemoveInput from node Retejs

In my editor, i have defined a type of node that only has inputs. These inputs are dynamically added based on the need of my user. I want to make it possible to dynamically delete these inputs as well.

I am able to retrieve the node id and the input to be deleted id. i am then trying to delete it using

editor.getNode(nodeID).removeInput(inputId);

I am checking that everything exist through some logs but the function removeInput does not seem to be working. I also cannot find anything about it in the documentation but when i type editor.[…] it does propose removeInput so it must mean that it would be possible.

MongoServerError: E11000 duplicate key error when trying to add a video to a playlist in MongoDB

I’m working on a MERN stack application where I have a Playlist document in MongoDB that looks like this:

{
  _id: new ObjectId('663296c9ca082f17ba715a4c'),
  name: 'My Fav 02',
  videos: [ new ObjectId('6631c108d41dfb12d6d076cd') ],
  userId: new ObjectId('6631bd463f5fe83acfb4913c'),
  __v: 0
}

I’m trying to add a video with an ObjectId of ‘6631bd613f5fe83acfb49141’ to the videos array in the Playlist document. However, I’m encountering a MongoServerError: E11000 duplicate key error. The error message suggests that there’s already a video with the same ObjectId in the videos array. But as per my document, only ObjectId of ‘6631c108d41dfb12d6d076cd’ is present.

Here’s the error message:

MongoServerError: E11000 duplicate key error collection: 64f7351729e1ad75103e28fa_test.playlists index: videos_1 dup key: { videos: ObjectId('6631bd613f5fe83acfb49141') }

And here’s my API to add a video to a playlist:

router.put('/playlist/:id', authMiddleware, async (req, res) => {
    try {
        const playlist = await Playlist.findById(req.params.id);
        if (playlist.userId.toString() !== req.body.userId) {
            return res.status(403).json({ message: 'Forbidden' });
        }
        playlist.videos.push(req.body.videoId);
        await playlist.save();
        res.json({ message: 'Video added to playlist' });
    } catch (err) {
        res.status(500).json({ message: err.message });
    }
});

I’m not sure why I’m getting a duplicate key error when the ObjectId I’m trying to add doesn’t exist in the videos array. Any help would be appreciated.

React-native Expo build is just a blank page

I’ve been running into some problems with the apk build of my app. In expo-go it works perfectly fine without any type of errors, and same goes when building the apk.
The problem is that, when I install the apk, the app gets blocked on a white screen. To be specific, it loads a “loading screen” that gets displayed while the app is loading fonts. But after that, just blank.
This is a snippet of what I’m talking about:

useEffect(() => {
    async function loadFont() {
      await Font.loadAsync({
    [...fonts...]
      });
      setFontLoaded(true);
    }
    loadFont();
  }, []);

  if (!fontLoaded) {
    //console.log("helloooo");
    return <Text>Loading...</Text>
  }

  return (
    <NavigationContainer>
      <Drawer.Navigator 
    [...rest of the code...]

The point is… I have no idea how to figure this out. There’s no console to look at, and online I’ve seen very different opinions on this kind of error, from downgrading react-native-reanimated to changing ansync functions.
From what I saw online this could be related to drawer-navigator/navigationContainer

I can’t really follow this approach since I’d have to re-build the app for each small change and it takes like 1.30h of waiting most of the time. I’ve looked up on debugging with the adb tool but I have no idea how to deal with logs error and whatnot. Any tips? I really don’t know how make it “debuggable” or where to look to solve this issue. It’s getting frustrating since the app is pretty much completed and does everything right in expo, and yet as an apk… Thanks for your help!

Tried building several times, no result

How to define object in array using javascript? [closed]

i am new to coding and javascript. i am trying to define object and function within array in javascript.

below is my code,

const typeA = {
    name: 'typeA',
    description: 'A',
};

const typeAversion1 = {
    ...typeA,
    version: '1',
};

const typesX = new Array(12).fill().map(() => ({
    name: `type X ${increment('type')}`,
    description: 'this is type x',
}));


const types = [
    typeA,
    ...typesX,
];

Now the question is how can i move the above definitions into the types const rather than defining them outside the const types. could someone help me with this. thanks.

EDIT:

i understand we could do something like below,

const  types = [
    {
        name: 'typeA',
        description: 'A',
    },
    {
        ...typeA,
        version: '1',
    },
    new Array(12).fill().map(() => ({
        name: `type X ${increment('type')}`,
        description: 'this is type x',
    }));
];

and you can access like so,

types[0]
types[1]
types[2]

But i want to access with their names if possible instead of array indexes. is it possible? thanks.

Getting npm ERR! code ENOMEM when trying to install npm in a remix project

When I run npm install in my Remix js project, I get the following errors:

npm ERR! code ENOMEM
npm ERR! syscall spawn
npm ERR! errno -12
npm ERR! spawn ENOMEM

I’ve already tried the following commands but still getting the above errors:

export NODE_OPTIONS=--max_old_space_size=4096
sudo /bin/dd if=/dev/zero of=/var/swap.1 bs=1M count=1024
sudo /sbin/mkswap /var/swap.1
sudo /sbin/swapon /var/swap.1 

Then I tried installing with htop on to see the live preview of Mem and Cpu usage and here’s the result:

enter image description here

It uses up all of the Cpu, Mem and Swp Mem of the server. So, what can I do to resolve this error?

Thanks!

How do I dynamically change the content of my web page for different countries?

I’m currently working on a project for a “Digital Marketing Agency” and I’m looking to enhance the user experience by customizing the content of our landing page based on the user’s geographical location.

The goal is to dynamically alter the content of the website depending on the country from which the user is accessing. For instance, if a user from the USA searches for “Digital Marketing Agency” on Google and lands on our page, I’d like the content to automatically update to include keywords such as “Top Digital Marketing Agency in the USA”.

I’m seeking advice on the best practices to achieve this. Specifically, I’m interested in:

  • Reliable methods for accurately determining the user’s location (IP-based, GPS, etc.).
  • Techniques for dynamically updating the web page content without requiring a page reload.
  • Any potential privacy considerations that I should be aware of when implementing this feature.

Any guidance, resources, or code examples would be greatly appreciated.

Thank you in advance for your help!

Ionic IonSplitPane adjusable size

I have this sample code that use IonSplitPane, What I want here is that in the Main View or Center View have a button that if i click the Left Menu it will close the left menu and the main view or Center View will automatic adjust the size, same behavior with the right menu.

this is my sample code

import React, { useState } from 'react';
import { IonContent, IonHeader, IonMenu, IonSplitPane, IonTitle, IonToolbar, IonButton } from '@ionic/react';

function Example() {
  const [leftMenuOpen, setLeftMenuOpen] = useState(false);
  const [rightMenuOpen, setRightMenuOpen] = useState(false);

  const toggleLeftMenu = () => {
    setLeftMenuOpen(!leftMenuOpen);
  };

  const toggleRightMenu = () => {
    setRightMenuOpen(!rightMenuOpen);
  };

  const closeLeftMenu = () => {
    setLeftMenuOpen(false);
  };

  const closeRightMenu = () => {
    setRightMenuOpen(false);
  };

  return (
    <IonSplitPane when="xs" contentId="main">
      <IonMenu contentId="main" side="start" menuId="left" isOpen={leftMenuOpen} onIonDidClose={() => setLeftMenuOpen(false)} onIonDidOpen={() => setLeftMenuOpen(true)}>
        <IonHeader>
          <IonToolbar color="tertiary">
            <IonTitle>Left Menu</IonTitle>
          </IonToolbar>
        </IonHeader>
        <IonContent className="ion-padding" onClick={closeLeftMenu}>Left Menu Content</IonContent>
      </IonMenu>

      <IonMenu contentId="main" side="end" menuId="right" isOpen={rightMenuOpen} onIonDidClose={() => setRightMenuOpen(false)} onIonDidOpen={() => setRightMenuOpen(true)}>
        <IonHeader>
          <IonToolbar color="tertiary">
            <IonTitle>Right Menu</IonTitle>
          </IonToolbar>
        </IonHeader>
        <IonContent className="ion-padding" onClick={closeRightMenu}>Right Menu Content</IonContent>
      </IonMenu>

      <div className="ion-page" id="main">
        <IonHeader>
          <IonToolbar>
            <IonTitle>Main View</IonTitle>
            <IonButton slot="start" onClick={toggleLeftMenu}>Toggle Left Menu</IonButton>
            <IonButton slot="end" onClick={toggleRightMenu}>Toggle Right Menu</IonButton>
          </IonToolbar>
        </IonHeader>
        <IonContent className="ion-padding">Main View Content</IonContent>
      </div>
    </IonSplitPane>
  );
}

export default Example;

Unable to change content of Slate.js component when providing new initialValue, editor content remains same as it was

Im trying to make a text editor app in which user can have multiple editors like notion, i have made the text editor using Slate.js, React, TypeScript. Currently I only have one editor and im storing it’s content in localStorage.

I have also implemented a sidebar which displays editors, when user selects any editor, the currentEditor state changes but the content in Slate editor does not change. Although the title gets changed which means currentEditor state is changing but im unable to change content of editor even after passing new editor’s value.

Earlier i was using a custom hook. Now i have shifted to Redux Toolkit to manage editors.

Attaching my code for reference:
App.tsx:

function App() {
    const currentEditor = useAppSelector((state) => state.editors.currentEditor);

    // to make editor to be stable across renders, we use useState without a setter
    // for more reference
    const [editor] = useState(withCustomFeatures(withReact(createEditor())));

    // defining a rendering function based on the element passed to 'props',
    // useCallback here to memoize the function for subsequent renders.
    // this will render our custom elements according to props
    const renderElement = useCallback((props: RenderElementProps) => {
        return <Element {...props} />;
    }, []);

    // a memoized leaf rendering function
    // this will render custom leaf elements according to props
    const renderLeaf = useCallback((props: RenderLeafProps) => {
        return <Leaf {...props} />;
    }, []);

    if (!currentEditor) {
        return <div>loading</div>;
    }

    return (
        <div className="h-full flex">
            <div className="flex h-screen w-60 flex-col inset-y-0">
                <div className="h-full text-primary w-full bg-white">
                    <NavigationSidebar />
                </div>
            </div>
            <main className="w-full">
                <div className="bg-sky-200 flex flex-col h-screen w-full">
                    <div className="text-center mt-4">
                        <h1 className="text-xl">{currentEditor?.title}</h1>
                    </div>
                    <div className="bg-white mx-auto rounded-md my-10 w-4/5">
                        {currentEditor && (
                            <EditorComponent
                                editor={editor}
                                renderElement={renderElement}
                                renderLeaf={renderLeaf}
                            />
                        )}
                    </div>
                </div>
            </main>
        </div>
    );
}

export default App;

Editor.tsx:

const EditorComponent: React.FC<EditorProps> = ({
    editor,
    renderElement,
    renderLeaf,
}) => {
    const { setSearch, decorate } = useDecorate();
    const dispatch = useAppDispatch();

    const currentEditor = useAppSelector((state) => state.editors.currentEditor);

    if (!currentEditor) {
        return <div>Loading</div>;
    }

    return (
        // render the slate context, must be rendered above any editable components,
        //  it can provide editor state to other components like toolbars, menus
        <Slate
            editor={editor}
            initialValue={currentEditor.value}
            // store value to localStorage on change
            onChange={(value) =>
                dispatch(
                    storeContent({
                        id: currentEditor.id,
                        title: currentEditor.title,
                        value,
                        editor,
                    })
                )
            }
        >
            {/* Toolbar */}
            <Toolbar/>
            <HoveringToolbar />
            {/* editable component */}
            <div className="p-3 focus-within:ring-2 focus-within:ring-neutral-200 focus-within:ring-inset border">
                <Editable
                    spellCheck
                    autoFocus
                    className="outline-none max-h-[730px] overflow-y-auto"
                    renderElement={renderElement}
                    renderLeaf={renderLeaf}
                    decorate={decorate}
                     
                     
                />
            </div>
        </Slate>
    );
};

export default EditorComponent;

NavigationSidebar.tsx:

const NavigationSidebar = () => {
    const editors = useAppSelector((state) => state.editors.editors);
    const currentEditor = useAppSelector((state) => state.editors.currentEditor);
    const dispatch = useAppDispatch();
    return (
        <div className="flex flex-col gap-y-4 items-center">
            <div className="text-center py-4 px-2 border-b-2 w-full">
                <h3 className="font-semibold text-xl text-indigo-500">Editors list</h3>
            </div>
            <div className="w-full">
                <ol>
                    {editors.map((editor) => (
                        <li key={editor.id}>
                            <button
                                className={`w-full py-2 border-b hover:bg-indigo-100 text-center ${
                                    currentEditor!.id === editor.id ? "bg-indigo-200" : ""
                                }`}
                                onClick={() => dispatch(setCurrentEditor(editor.id))}
                            >
                                {editor.title}
                            </button>
                        </li>
                    ))}
                </ol>
                <button
                    className="border-b py-2 w-full hover:bg-indigo-100"
                    onClick={() => dispatch(addNewEditor())}
                >
                    New blank editor
                </button>
            </div>
        </div>
    );
};

editorSlice reducers:

reducers: {
        addNewEditor: (state) => {
            const newEditor: EditorInstance = {
                id: `editor${state.editors.length + 1}`,
                title: `Editor ${state.editors.length + 1}`,
                value: [
                    {
                        type: "paragraph",
                        children: [
                            { text: "This is new editable " },
                            { text: "rich", bold: true },
                            { text: " text, " },
                            { text: "much", italic: true },
                            { text: " better than a " },
                            { text: "<textarea>", code: true },
                            { text: "!" },
                        ],
                    },
                ],
            };
            state.editors.push(newEditor);
            localStorage.setItem("editorsRedux", JSON.stringify(state.editors));
            state.currentEditor = newEditor;
        },
        setCurrentEditor: (state, action: PayloadAction<string>) => {
            const selectedEditor = state.editors.find(
                (editor) => editor.id === action.payload
            );

            if (selectedEditor) {
                state.currentEditor = selectedEditor;
            }
        },
        loadEditorsFromLocalStorage: (state) => {
            const storedEditors = localStorage.getItem("editorsRedux");
            if (storedEditors) {
                state.editors = JSON.parse(storedEditors);
                state.currentEditor = state.editors[0];
            } else {
                const initialEditor: EditorInstance = {
                    id: "editor1",
                    title: "Untitled",
                    value: [
                        {
                            type: "paragraph",
                            children: [
                                { text: "This is editable " },
                                { text: "rich", bold: true },
                                { text: " text, " },
                                { text: "much", italic: true },
                                { text: " better than a " },
                                { text: "<textarea>", code: true },
                                { text: "!" },
                            ],
                        },
                    ],
                };

                state.editors = [initialEditor];
                state.currentEditor = initialEditor;
                localStorage.setItem("editorsRedux", JSON.stringify(state.editors));
            }
        },

        storeContent: (
            state,
            action: PayloadAction<{
                id: string;
                title: string;
                value: Descendant[];
                editor: Editor;
            }>
        ) => {
            const title = action.payload.title;
            const value = action.payload.value;
            const isAstChange = action.payload.editor.operations.some(
                (op) => "set_selection" !== op.type
            );
            if (isAstChange) {
                if (state.currentEditor) {
                    const updatedEditors = state.editors.map((editor) => {
                        if (editor.id === action.payload.id) {
                            return { ...editor, title, value };
                        }
                        return editor;
                    });
                    state.editors = updatedEditors;
                    localStorage.setItem("editorsRedux", JSON.stringify(state.editors));
                }
            }
        },
    },

I want to know that do we have to initialzie a new slate editor every time when user changes or only change the editor’s initialValue prop by passing currentEditor.value or do we have to use routing to change the initialValue of Slate. Help is very much appreciated.

What happened to bootstrap installation to my project?

everything worked properly earlier, but now I launched my website and the carousel was broken. The same was with the buttons and etc.

What happened to bootstrap?
I guess there is smth wrong with the CDN. I see bootstrap’s buttons and sliders, but they don’t work properly.

My index.html:

    <!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>Факультет экономики, психологии, менеджмента</title>
    <link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-QWTKZyjpPEjISv5WaRU9OFeRpok6YctnYmDr5pNlyT2bRjXh0JMhjY6hW+ALEwIH" crossorigin="anonymous">
    <link rel="stylesheet" href="styles.css">
</head>
<body class="bg-dark">

<div class="container text-center mt-5">
    <h1>Факультет экономики, психологии, менеджмента!!!</h1>
    <h2>История</h2>

  <div id="carouselExampleIndicators" class="carousel slide carousel-fade" data-bs-ride="carousel">
  <div class="carousel-indicators">
    <button type="button" data-bs-target="#carouselExampleIndicators" data-bs-slide-to="0" class="active" aria-current="true" aria-label="Slide 1"></button>
    <button type="button" data-bs-target="#carouselExampleIndicators" data-bs-slide-to="1" aria-label="Slide 2"></button>
    <button type="button" data-bs-target="#carouselExampleIndicators" data-bs-slide-to="2" aria-label="Slide 3"></button>
  </div>
  <div class="carousel-inner">
    <div class="carousel-item active">
      <img src="images/slide1.jpg" class="d-block w-100" alt="...">
    </div>
    <div class="carousel-item">
      <img src="images/slide2.jpg" class="d-block w-100" alt="...">
    </div>
    <div class="carousel-item">
      <img src="images/slide3.jpg" class="d-block w-100" alt="...">
    </div>
  </div>
  <button class="carousel-control-prev" type="button" data-bs-target="#carouselExampleIndicators" data-bs-slide="prev">
    <span class="carousel-control-prev-icon" aria-hidden="true"></span>
    <span class="visually-hidden">Previous</span>
  </button>
  <button class="carousel-control-next" type="button" data-bs-target="#carouselExampleIndicators" data-bs-slide="next">
    <span class="carousel-control-next-icon" aria-hidden="true"></span>
    <span class="visually-hidden">Next</span>
  </button>
</div>


    <div class="row mt-5">
        <div class="col-md-4">
            <a href="economic.html" class="btn btn-outline-warning btn-lg w-100">
                <div class="card">
                    <img src="images/economic.jpg" class="card-img-top" alt="Economic Faculty">
                    <div class="card-body">
                        <h5 class="card-title">Экономический факультет</h5>
                    </div>
                </div>
            </a>
        </div>
        <div class="col-md-4">
            <a href="international.html" class="btn btn-outline-warning btn-lg w-100">
                <div class="card">
                    <img src="images/international.jpg" class="card-img-top" alt="International Business Faculty">
                    <div class="card-body">
                        <h5 class="card-title">Факультет международного бизнеса</h5>
                    </div>
                </div>
            </a>
        </div>
        <div class="col-md-4">
            <a href="psychology.html" class="btn btn-outline-warning btn-lg w-100">
                <div class="card">
                    <img src="images/psychology.jpg" class="card-img-top" alt="Psychology Faculty">
                    <div class="card-body">
                        <h5 class="card-title">Факультет психологии</h5>
                    </div>
                </div>
            </a>
        </div>
    </div>
</div>


<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js" integrity="sha384-YvpcrYf0tY3lHB60NNkmXc5s9fDVZLESaAA55NDzOxhy9GkcIdslK1eN7N6jIeHz" crossorigin="anonymous"></script>

</body>
</html>

My styles.css:

/* styles.css */
body {
    background-color: #738394;
    font-family: 'Roboto', sans-serif;
}

h1 {
    color: #F8F8FF;
    font-family: 'Montserrat', sans-serif;
}

.carousel-item img {
    height: 400px;
    object-fit: cover;
}

.card {
    cursor: pointer;
    transition: transform 0.3s;
}

.card:hover {
    transform: scale(1.05);
}

.btn {
    background-color: #FF4500;
    border-color: #FF4500;
    color: #FFFFFF;
}

.btn:hover {
    background-color: #DC370B;
    border-color: #DC370B;
    color: #FFFFFF;
}

.card-body {
    background-color: #FFFFFF;
}

.container.text-center {
    background-color: #808080;
    padding: 30px;
    border-radius: 10px;
    box-shadow: 0px 0px 20px 0px rgba(0,0,0,0.1);
}


Now it’s smth like this:enter image description here

But it was: enter image description here

upd: buttons are broken too
enter image description here

I got this in my browser (opera, F12 – Network):
enter image description here

How to return data promise with funtion from looping parameter data

How can i return this promise data in template with function and parameter data looping?
this was my code:

  let data = [
    {
      id: 1,
      model: "DIY-MULTI3-27HP230C"
    }
  ]

  const getByModelNo = async ({ id, params }: { id: string, params?: AxiosRequestConfig }) => {
    const options = {
      method: 'GET',
      url: `${prefix}/${id}`,
      params
    };
    let data: DataFromModel | any = {};
    try {
      const response = await axios.request(options);
      data = response?.data?.data
    } catch (error) {
      console.error('Error fetching configurator-post:', error);
    }
    return data;
  }
  )

i want the result can return like this example:

  return(
   <div>
     {data.map((items, index) => (
        <div key={index}>{getByModelNo({id: items.model}).seriesName }</div>
       )
     )}
   </div>

Middleware can not access the cookie after deployment but locally it can access the cookies in next js

I have a NextJS application as a frontend application; for the backend, I am using the NodeJS ExpressJS application. Here, I implemented JWT token-based authentication and authorization. So I am setting the only JWT token from the backend server. On the frontend server, I am accessing the token. If I can access the token from the NextJS app, then I permit users to access private routes. So my problem is that when I am running my applications locally, they are running well, and I have not faced any issues. But after deployment, it has been setting cookies in the frontend browser well, but it can not send cookies when I am trying to access private routes from the frontend. MiddlewareJS cannot access the cookies.

middleware.js in next js application :

import { NextResponse } from 'next/server';
import react from 'react';

const middleware = (req) => {

    let verify = req.cookies.get("jwt")
    let url = req.url
    if (!verify && url.includes("/dashboard")) {
       
        return NextResponse.redirect(`${process.env.NEXT_URL}/login`);
    }

};
export default middleware;

index.js cors in express application :

if(process.env.NODE_ENV==="Production"){
  corsOptions = {
    credentials: true, origin:process.env.ORIGIN_URL 
  };
}else{
  corsOptions = {
    credentials: true, origin:true
  };
}

app.use(cors(corsOptions))

protectMiddleware in express js application :

const protect = asyncHandler(async (req, res, next) => {
  let token;
  token=req.cookies?.jwt
  console.log(token)
  if (token) {
    try {
      const decoded = jwt.verify(token, process.env.JWT_SECRET);
      console.log(decoded)
      req.user = await prisma.user.findFirst({
        where: {
          email: decoded.email,
        },

      });
      next();
    } catch (err) {
      res.status(401);
      throw new Error(`Not Authorized, Invalid Token`);
    }
  } else {
    res.status(401);
    throw new Error(`Not Authorized, No Token`);
  }
});

Note : Here my Next js and backend are in different domain backend and frontend are running in https.

How can it be run without issue after deployment and middleware js will access the cookie into the next js application after deployment?
is there any solution ?
Thank you so much .