why can’t I get JSESSIONID from browser cookies in production using javascript?

i want to retrieve JSESSIONID from browser cookies. when I do in local environment i can get it. but when it’s in production I can’t get it. In below I will give you the difference between my cookies on local and production. And also I have attached the source code that I use.

I want to ask, why did this happen? How can I get JSESSIONID correctly?

Production

enter image description here

Local

enter image description here

sessionId () {
  const cookies = document.cookie.split(';')
  const cookiesObj = Object.fromEntries(document.cookie.split('; ').map(c => c.split('=')))
  const jSessionId = cookiesObj.JSESSIONID
  console.log('All cookies:', cookies) // Log all cookies
  console.log('cookiesObj: ', cookiesObj)
  console.log('JSESSION from object: ', jSessionId)

  for (let i = 0; i < cookies.length; i++) {
    console.log(cookies)
    const cookie = cookies[i]
    console.log('Current cookie:', cookie) // Log current cookie
    console.log('| jSessionId | ' + jSessionId + ' | JSESSIONID | ' + cookie.startsWith('JSESSIONID=') + ' | (spasi)JSESSIONID | ' + cookie.startsWith(' JSESSIONID='))

    if (jSessionId || cookie.startsWith('JSESSIONID=') || cookie.startsWith(' JSESSIONID=')) {
      const sessionId = jSessionId || cookie.substring('JSESSIONID='.length, cookie.length) || cookie.substring(' JSESSIONID='.length, cookie.length)
      console.log('Extracted session ID:', sessionId) // Log extracted session ID
      return sessionId
    }
  }

  return null
},

This is the result from this line > console.log(‘All cookies:’, cookies)

I try to get all cookies, but JSESSIONID. But JSESSIONID cannot be found and is not in the array

['_ga=GA1.1.65081268.1674548249', ' __zlcmid=1E5lY8RBkVpH3HE', ' _fbp=fb.2.1676598513649.1894969411', ' _gcl_au=1.1.1175302720.1682471982', ' SERVERUSED=nuxtserver1', ' _ga_SQ0WWF9CV8=GS1.1.1689055593.182.0.1689055593.60.0.0', ' DRM_STORE=%7B%22user%22%3A%7B%22userData%22%3A%7B…ser_id%22%3A%2217%22%2C%22wa%22%3A%22%22%7D%7D%7D', ' _ga_SP8DGHSHWB=GS1.1.1689059746.69.1.1689059927.0.0.0']

Monogo db no longer supports callback

export const addNewPlayer = (req, res) => {
    let newPlayer = new Player(req.body);

    newPlayer.save((err,Player) => {
        if(err){
            res.send(err);
        }
        res.json(Player);
});

i am new to this i am getting “No longer accepts a callback” error, how can i solve this without downgrading the current MongoDB version.

i tried testing POST in postman to save new player details. but getting mentioned error”No longer supports a callback”

Select specific javascript parts of the bootstrap.min.js of Bootstrap to reduce its size

I am building a site with Bootstrap, but I would like to reduce the size of the Javascript botstrap.min.js file. I would like to use only those few JS parts that I use and are currently only offcanvas.js and dropdown.js. I tried several ways sought on the web, but I did not succeed. As the last way I simply tried this (but it doesn’t work even):

<script src="js/offcanvas.js"></script>
<script src="js/dropdown.js"></script>

The solutions found on the web are these two of the Bootstrap website: Lean JavaScript or Webpack e bundler, but I don’t know how to apply them because I didn’t understand much about the explanation.

I have already reduced the size of the CSS file with Sass and Scss and with Purgecss, but I have no idea how I can do the same for bootstrap.min.js. As for the reduced CSS, I would like to have only one file to import (for example my-bootstrap.js) in which Impbiesto aganvas.js and dropdown.js in it

Someone can show me a practical example of how I can reduce the bootstrap.min.js file and select only the specific parts I use?

What is Schema Markup and what is its use for SEO?

Recently, I built a website sharecy.net and prepared to do Google seo by myself, so I found a lot of related information about google seo on the Internet; I accidentally found a very useful seo plug-in seoquake.
I tested my website through seoquake, and it gave several optimization suggestions after analysis, one of which said that my website did not mark Schema Markup. But I don’t know what this means, what should I do?
Then I tried to generate the Schema Markup structure according to the online tutorial, on this page, https://www.sharecy.net/?id=40
I hope that some professional friends can help me to see if there is any problem, thank you!

I hope that a professional friend can help me to see if there is any problem with the Schema Markup structure, thank you!

How can I let the `range.values` fill in as an array even if I only select one cell in excel?

So I have this code about getting a distance using Google API and JavaScript to an Excel file:[enter image description here][1]

    Office.onReady((info) => {
  if (info.host === Office.HostType.Excel) {
    document.getElementById("sideload-msg").style.display = "none";
    document.getElementById("app-body").style.display = "flex";
    document.getElementById("run").onclick = run;
  }
});

// Get directionsData.distance.text from taskpane.html
var jarak = localStorage.getItem("distanceValue");

// "Type in excel" code
export async function run() {
try {
  await Excel.run(async (context) => {
  /**
   * Insert your Excel code here
   */
  const range = context.workbook.getSelectedRange();

  // Read the range address
  range.load("address");

  // Fill in the value
  range.values = jarak;

  await context.sync();
  console.log(`The range address was ${range.address}.`);
});
} catch (error) {
console.error(error);
}
}

What I’d like to ask is if I change the range.values = jarak; to range.values = [[jarak], [latitude], [longitude]]; (The additional parameters will be defined later).

I want the code to let me only select one cell from excel and it fills the next 2 cells (using the new range.values I defined here will add it to the next column). The problem is that I have to select the 3 cells in order to let the excel fills the new range.values which is an array if I recall the name correctly.

How can I let the range.values fills in as an array even if I only select one cell in excel?

The excel interface I made is like this: https://i.stack.imgur.com/Nh3YG.png

Is it wrong to place the tag after the tag? [duplicate]

I was reading this book. In one of the codes in chapter 5 of the book, I saw the code below:

<!-- index.html file -->
<html>
<head>
  <meta charset="utf-8" />
  <script src="https://unpkg.com/vue@next"></script>
</head>
<body>
<div id="app"></div>
</body>

<script type="module">

  import GlobalApp from "./global-app.js";

  var app = Vue.createApp({
    components : {
      GlobalApp:GlobalApp
    },
    template : "<GlobalApp />"
  });

  var vm = app.mount("div#app");

</script>
</html>

That code is for a main html file that runs a vue app (not in SFC format). If you notice the code, it put script type="module" tag after </body> tag. I know that there are some similar questions like this one in this problem. But I could not found anything about script type="module" in none of them. I want to know that is this usage wrong or non-valid that we put script type="module" after </body>?

Application won’t work after disconnecting from RDP

The problem is that my Java Script runs perfectly fine when I have a connection with RDP to my Windows Server but when I disconnect (Clicking X) as title says my Script wont work as expected.

It is recieving the requests from my website but can’t do the tasks properly such as FFMpeg.

Error adding banner to the video: Error: ffmpeg exited with code 1:
at ChildProcess. (C:Usersdurieun02Desktopservernode_modulesfluent-ffmpeglibprocessor.js:182:22)
at ChildProcess.emit (node:events:513:28)
at ChildProcess._handle.onexit (node:internal/child_process:291:12)

This is just an explanation error, in reality my process is not even working.

And such more errors like this when I am disconnected, The whole point of me opening a VM was to keep my actual PC offline while server would run for me in the background.

I have also tried running my Script as a background process but it didn’t worked either. It still somehow didn’t have the permissions or something, not really sure why.

I also edited gpedit.msc and Edited necessary things such as “Session Time Limits” but its not revelant at all since my session is not turning off but rather function don’t work properly when RDP is not connected.

I have also trying running it as a scheduled task and windows service, the problem is still same, the script runs but its not working as expected, my website esentiially returns the errors.

Thanks for the helps, I hope we can find a solution for all.

Pixel Streaming Matchmaking issue: ‘WARNING: No empty Cirrus Servers are available’

I’ve been working on issue for some days, but I can’t figure out any solutions…

I’m testing this in Local computer.

  • I’m using default Pixel Streaming Matchmaker from github ‘EpicGames/PixelStreamingInfrastructure’.

  • I’m also using default Start_SignallingWebServer.ps1 from same repository.

  • I’ve Opened Port in my Windows Firewall Advanced Settings.

  • I found similar question asked here, but there were answers on.

  1. When I Open Matchmaker by open ‘run.bat’ from ‘PixelStreamingInfrastructureMatchmakerplatform_scriptscmd’, it works well.

Matchmaker run.bat

  1. After Open Matchmaker, I Open Start_SignallingWebServer with PowerShell,
    and it connects to Matchmaker without issue.

SignallingWebServer connect to Matchmaker

  1. Then I Open Unreal Instances(Application that I built from Unreal Project with Pixel Streaming Plugin)
    it Connects to SignallingWebServer without issue.

Unreal Instance connected to SignallingWebServer

  1. When I checked matchmaker.js from ‘PixelStreamingInfrastructureMatchmaker’, I found in function ‘getAvailableCirrusServer()’, when cirrusServer’s numConnectedClients is 0, and ready is true, it returns cirrusServer itself.

Matchmaker getAvailableCirrusServer()

  1. So, in the ‘ping’ message from matchmaker, I added console.log which is

Matchmaker Ping Message Log

console.log(Number of Clients in ${cirrusServer.address}:${cirrusServer.port}: ${cirrusServer.numConnectedClients}, ${cirrusServer.ready});

When I check this log in Matchmaker’s run.bat file running, it shows log

Matchmaker console log
’11:17:59.646 Number of Clients in MyIPAddress: 0, true’

This means that getAvailableCirrusServer() have to return cirrusServer, as there is no clients connected to signallingwebserver that I opened, and also instance is connected to signallingwebserver, so Matchmaker should be able to redirect any clients connected to itself to signallingwebserver.

But it doesn’t work as I imagined. When I open Chrome browser and enter to Matchmaker’s IP Address and Port,

Matchmaker not working

it shows message like this – ‘WARNING: No empty Cirrus servers are available’.

This log should be printed when getAvailableCirrusServer() failed to find any cirrusServer (which is SignallingWebServer).

But as you see in the picture (Matchmaker getAvailableCirrusServer), I’ve added some console.log to check whether the function enters if branch, and it actually enters, as you see in the picture above.

However, at the same time, it also shows log outside the loop, which is very awkward to me… because when the function already enters if statement, it has to return cirrusServer and get out from the function, but it is not working like that right now.

I want to know why the logs that shouldn’t be printed at same time is actually printing at same time, and ultimately solve this Matchmaking server issue (No empty Cirrus Servers)…

Would be grateful if someone provide me any ideas!

Next.JS 13 Firebase Storage: No default bucket found

Using Next.JS 13 and Firebase V9.

I have been able to make requests to Cloud Firestore successfully without issue. I believe my firebase app is configured correctly. I cannot identify the issue with my Cloud Storage setup though. Every time I try to get a ref and download a Cloud Storage file, I am met with No default bucket found. I made sure to initialize the storage bucket with files in the Firebase Console before I attempted this. I have tried numerous variations of implementation from Bard, Stackoverflow, and elsewhere, and I am certain it’s probably just a minor thing I’ve overlooked, but I can’t seem to narrow down the issue for the life of me.

Here is my Firebase.js file in my main project directory.

// Import the functions you need from the SDKs you need
import { initializeApp, getApp, getApps} from "firebase/app";
import { getFirestore } from "firebase/firestore";
import { getStorage} from "firebase/storage";
// TODO: Add SDKs for Firebase products that you want to use
// https://firebase.google.com/docs/web/setup#available-libraries

// Your web app's Firebase configuration
const firebaseConfig = {
  apiKey: process.env.FIREBASE_APIKEY,
  authDomain: process.env.FIREBASE_AUTHDOMAIN,
  projectId: process.env.FIREBASE_PROJECTID,
  storageBucket: process.env.FIREBASE_STORAGEBUCKET,
  messagingSenderId: process.env.FIREBASE_MESSAGEID,
  appId: process.env.FIREBASE_APPID,
  // For Firebase JS SDK v7.20.0 and later, measurementId is optional
  measurementId: process.env.FIREBASE_MEASUREMENTID
};

// Initialize Firebase
const app = !getApps().length ? initializeApp(firebaseConfig) : getApp();
const db = getFirestore(app);
const storage = getStorage(app);

//Export relevant modules
export { app, db, storage };

and here is the FileService file I’ve been trying to call when clicking a button on the website, which results in the no storage bucket found error.

import { storage } from "@/firebase"
import { ref, getDownloadURL } from "firebase/storage";

const downloadFile = async (fileName: string) => {
    const storageRef = await ref(storage);
    const file = await ref(storageRef, fileName);

    // Download the file to the specified location.
    await fetch(await getDownloadURL(file), {
        method: "GET",
        mode: "cors",
        headers: {
        "Content-Type": "application/pdf",
        },
    });
};

export default downloadFile;

I’ve also attempted to get a storageRef inside the Firebase.js file just to see if that would work but it throws the error there as well. I appreciate any guidance, I spent a long time trying to figure this one out and I wouldn’t be surprised if I’m doing overlooking something small and stupid but I need a third party to point me in the right direction here.

Recoil: Triggering a function on atom change

I’m trying to store a user object inside an atom and have it be cached inside localStorage each time it changes because the app might crash and I do not want the user to have to sign in every time:

localStorage.setItem('user', JSON.stringify(user))

Previously when I used useContext this was achieved through a useEffect in the parent component (App.js) that monitored the user object for changes. It’s no longer possible for me to do this after migrating from useContext to Recoil due to my NextJS project structure (RecoilRoot wraps around the children component, so the parent App.js itself does not have access to useRecoil methods). And so, I’m wondering if there’s a way to implement this kind of listener or callback using a built-in Recoil method

Desired process:

  1. Declare the state: const [user, setUser] = useRecoilState(userAtom)
  2. Trigger a change setUser({...})
  3. Trigger a callback on state change localStorage.setItem('user', JSON.stringify(user))

Using JS array splice in one line and two lines got different result

Code 1:

let targetArr = ["hello", "world", "my", "name"];
let errnewArr = Array.from(targetArr).splice(2, 1);
console.log("errnewArr array : "+errnewArr.length);

Code 2:

targetArr = ["hello", "world", "my", "name"];
let newArr = Array.from(targetArr);
newArr.splice(2, 1);
console.log("new array : "+newArr.length);

As you can see the code are similar logic, just the splice method is place after the Array.from or in a newArr, but the result is very different, the errnewArr got the length: 1, but the new array got the length: 3.

Why the result is look like that?

Module not found error when integrating a chatbot into a website

I am trying to integrate a chatbot into my website. Previously, the chatbot code was in a separate folder, but I have now merged it within my website codebase to have everything in one place. When I try to add the chatbot to my website by including in my code, I encounter the following error:

ERROR in ./src/App.js 16:0-92
Module not found: Error: Can't resolve './components/layout/chatbot-solicitors-website/chatbot-deployment/app' in '/Users/parisvinuya/Dropbox/Mac/Desktop/Solicitor's Website/solicitors-website/src'

Here is the code snippet from my app.js file:

import { Routes, Route } from "react-router-dom";
import appcss from "./App.module.css";

import AboutUs from "./pages/AboutUs";
import BookOnline from "./pages/BookOnline";
import Firm from "./pages/Firm";
import Home from "./pages/Home";
import LogIn from "./pages/LogIn";
import Publications from "./pages/Publications";
import Navbar from "./components/layout/Navbar";
import Footer from "./components/layout/Footer";
import ContactUs from "./components/layout/ContactUs";
import ChatWithUsButton from "./components/layout/ChatWithUsButton";
import ChatBot from "./components/layout/chatbot-solicitors-website/chatbot-deployment/app";

function App() {
  return (
    <div className={appcss.pagecontainer}>
      <div className={appcss.contentwrap}>
        <Navbar />
        <Routes>
          <Route path="/about-us" element={<AboutUs />} />
          <Route path="/book-online" element={<BookOnline />} />
          <Route path="/firm" element={<Firm />} />
          <Route path="/home" element={<Home />} />
          <Route path="/login" element={<LogIn />} />
          <Route path="/publications" element={<Publications />} />
        </Routes>
      </div>
      <ChatBot />
      <ChatWithUsButton />
      <ContactUs />
      <Footer />
    </div>
  );
}

export default App;

And here is my app.py file containing the Flask backend code under the file pathway ‘./components/layout/chatbot-solicitors-website/chatbot-deployment/app’:

from flask import Flask, render_template, request, jsonify

from chat import get_response

app = Flask(__name__)

@app.get("/")
def index_get():
    return render_template("base.html")

@app.post("/predict")                   
def predict():
   text = request.get_json().get("message")
   # TO-DO: check if text is valid
   response = get_response(text)
   message = {"answer": response}
   return jsonify(message)

if __name__ == "__main__":
    app.run(debug=True, port=5001)

The chatbot code is located at “./components/layout/chatbot-solicitors-website/chatbot-deployment/app”. However, when I try to include the ChatBot component, I receive the “Module not found” error.

I have verified that the file path is correct, and I have already merged the chatbot code within my website’s codebase. Can anyone help me understand why I am encountering this error and how I can resolve it?

How can I display a default username value so I stop getting an undefined error?

I have a navbar which displays the following on the right side of the screen:

Welcome, <%= user %>

But in order for me to get the user I need to render it like so

router.get("/", function (req, res, next) {
  const user = req.user.username;
  res.render("index", user);
});

There’s obviously a problem with this as if I am not logged in, I’m not able to load the web page at all due to getting an undefined error: TypeError: Cannot read properties of undefined (reading 'username'). Is there a way for me to add a default value to user or even display a Sign Up button so I stop getting the TypeError?