upgrading react version and changing dls to filament

I am in the middle of upgrading the react version from 16 to 18.
now after upgrading successfully i changed to filament dls. Filament uses Vanilla Extract to generate static CSS files for Application and its theme configuration.

so, I added all the necessary dependencies including Vanilla and Vite.

Don’t know much about them and eager to learn.

this is my package.json

{
  "homepage": "./",
  "dependencies": {
    "@date-io/date-fns": "^1.3.13",
    "@emotion/react": "^11.14.0",
    "@emotion/styled": "^11.14.0",
    "@filament-icons/react": "^1.10.0",
    "@filament/next-plugin": "^3.1.10",
    "@filament/react": "^3.12.3",
    "@filament/vite-plugin": "^3.3.9",
    "@mui/icons-material": "^6.4.4",
    "@mui/lab": "^6.0.0-beta.27",
    "@mui/material": "^6.4.4",
    "@mui/x-date-pickers": "^7.26.0",
    "@testing-library/jest-dom": "^4.2.4",
    "@testing-library/react": "^9.5.0",
    "@testing-library/user-event": "^7.2.1",
    "bootstrap": "^4.5.0",
    "date-fns": "^2.30.0",
    "html-react-parser": "^5.2.2",
    "jquery": "^3.5.1",
    "lodash": "^4.17.19",
    "nprogress": "^0.2.0",
    "react": "18.3.0",
    "react-app-polyfill": "^1.0.6",
    "react-dom": "18.3.0",
    "react-inlinesvg": "^4.1.8",
    "react-intl": "^5.6.9",
    "react-redux": "^7.2.0",
    "react-redux-i18n": "^1.9.3",
    "react-router-dom": "^5.2.0",
    "react-scripts": "^5.0.1",
    "react-select": "5.10.0",
    "react-table": "^7.8.0",
    "reactstrap": "^8.5.1",
    "redux": "^4.0.5",
    "redux-thunk": "^2.3.0",
    "spm": "file:",
    "styled-components": "^5.3.3"
  },
  "scripts": {
    "npm:login": "npm login --registry=https://artifactory-ehv.ta.philips.com/artifactory/api/npm/edi-dmis-pb-npm/",
    "start": "react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test --env=jsdom",
    "coverage": "react-scripts test --env=jsdom --watchAll=false --coverage",
    "eject": "react-scripts eject"
  },
  "eslintConfig": {
    "extends": "react-app"
  },
  "browserslist": {
    "production": [
      ">0.2%",
      "not dead",
      "not op_mini all"
    ],
    "development": [
      "ie 11",
      "last 1 chrome version",
      "last 1 firefox version",
  

    "last 1 safari version"
    ]
  },
  "devDependencies": {
    "@babel/plugin-proposal-class-properties": "^7.18.6",
    "@babel/plugin-proposal-private-property-in-object": "^7.21.11",
    
    "redux-mock-store": "^1.5.4",
    "vite-plugin-vanilla-extract": "^0.0.0"
  },
  "jest": {
    "moduleNameMapper": {
      "\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga|pdf)$": "<rootDir>/__mocks__/fileMock.js",
      "\.(css|less)$": "<rootDir>/__mocks__/styleMock.js"
    },
    "coveragePathIgnorePatterns": [
      "<rootDir>/src/api/resource.js",
      "<rootDir>/src/i18n/",
      "<rootDir>/src/assets/",
      "<rootDir>/public/",
      "<rootDir>/src/serviceWorker.js",
      "<rootDir>/src/app.settings.js",
      "<rootDir>/src/index.js"
    ]
  },
  "packageManager": "[email protected]+sha512.a6b2f7906b721bba3d67d4aff083df04dad64c399707841b7acf00f6b133b7ac24255f2652fa22ae3534329dc6180534e98d17432037ff6fd140556e2bb3137e"
}

this is the error in the browser:-
enter image description here

any response will be a huge help. thank you in advance.

CORS Issue: Auth Cookie Gets Deleted After Redirect from Login to Dashboard (Deployed on Render/Vercel)

Problem Description

I am facing an issue with authentication cookies getting deleted after redirecting from the login page to the dashboard in my MERN stack application. The application works perfectly on localhost, but once deployed (backend on Render, frontend on Vercel), the authentication cookie is lost after redirection, leading to an “unauthorized” error.

Issue Breakdown:

  • I am using JWT tokens stored in HTTP-only cookies for authentication.
  • On login, the backend successfully sets the cookie, and I can verify it exists in the browser.
  • However, after redirecting from the login page to the dashboard, the cookie is no longer available, and requests to protected routes fail.
  • The issue only occurs in the deployed version, not in localhost.

Technical Setup:

  • Frontend: React.js (Vercel)
  • Dashboard: React.js (Vercel)
  • Backend: Express.js, MongoDB (Render)
  • Authentication: JWT stored in HTTP-only cookies
  • CORS Configuration:
    app.use(
      cors({
          origin: allowedOrigins,
          credentials: true,
      })
    
    

Troubleshooting Done:

  • Confirmed the cookie is set correctly on login.
  • Checked browser storage—cookie disappears after redirection.
  • Tried adding "sameSite": "none", secure: true while setting cookies.
  • Tried different backend hosting platforms (Render, Vercel).
  • Ensured both frontend and backend use HTTPS.

Despite these attempts, the issue persists. How can I ensure that the authentication cookie remains available after redirection?
(https://i.sstatic.net/CUb0e9tr.png)

What I Tried and Expected vs. Actual Result

I have been debugging this cookie deletion issue in my deployed MERN stack application, where the authentication token is stored in an HTTP-only cookie. Here’s what I attempted and what I observed:

1. Checking if the Cookie is Set Correctly on Login

  • What I Tried: After a successful login, I inspected the network tab and cookies storage in the browser.
  • Expected Result: The authentication cookie should be present and accessible in future requests.
  • Actual Result: The cookie is initially set correctly in localhost and the deployed version, but in deployment, it disappears after redirection to the dashboard.

2. Ensuring CORS is Configured Properly

  • What I Tried:
    const corsOptions = {
        origin: "https://zerodha-clone-tau.vercel.app",
        credentials: true, 
        optionsSuccessStatus: 200,
    };
    app.use(cors(corsOptions));
    
    • Also, in the frontend, I enabled credentials in Axios:
    axios.defaults.withCredentials = true;
    
  • Expected Result: The cookie should persist across requests.
  • Actual Result: Even with these settings, the authentication cookie disappears after redirection.

3. Adjusting Cookie Options in Express

  • What I Tried: Setting sameSite and secure options explicitly while sending the cookie:
    res.cookie("token", token, {
        httpOnly: true,
        secure: true,  // Required for HTTPS
        sameSite: "none", // Allow cross-site cookies
    });
    
  • Expected Result: The cookie should remain accessible across different pages.
  • Actual Result: Still, the cookie gets deleted after redirection when deployed.

4. Verifying HTTPS on Both Frontend and Backend

  • What I Tried:
    • Ensured both frontend (Vercel) and backend (Render) use HTTPS.
  • Expected Result: Secure cookies should work with HTTPS.
  • Actual Result: No change—cookie still gets deleted after redirect.

5. Trying Different Hosting Platforms

  • What I Tried:
    • Deployed the backend on Vercel instead of Render to see if the issue was platform-specific.
  • Expected Result: If Render was the issue, hosting on Railway should resolve it.
  • Actual Result: The problem persisted, meaning it’s not related to Render.

6. Checking Browser Behavior

  • What I Tried:
    • Opened the Application > Cookies tab in Chrome DevTools.
  • Expected Result: The cookie should persist even after redirection.
  • Actual Result: The cookie disappears after redirection to the dashboard.

Summary of My Observations

✅ Cookie is set successfully on login.
❌ Cookie is deleted after redirection to the dashboard.
❌ Issue occurs only in the deployed version (works fine on localhost).
❌ Tried all standard CORS, SameSite, Secure, and HTTPS fixes—still doesn’t work.

What could be causing the cookie to be deleted, and how can I make it persist across pages in the deployed version?
(https://i.sstatic.net/6pN7TzBM.png)

How to extract an address from a content using Python or JavaScript? [closed]

I am working on a project where I need to extract an address (example: street, city, state, Pincode) from a given content (such as a block of text), regardless of the format. Could anyone guide me on how to proceed with this task, either using Python or JavaScript?

Example text:

“A daring gold heist took place at Shree Lakshmi Jewelers on MG Road, Bengaluru, late Monday night. According to police officials, a group of masked burglars broke into the store around 2:30 AM and made away with gold and diamond jewelry worth over ₹5 crore.
CCTV footage revealed that the suspects arrived in a black SUV, which was later seen speeding towards Electronic City via Bannerghatta Road. The police suspect that the gang might have connections to Chennai and could be planning an escape towards Hosur. ‘We have intensified security checks at all major highways, including NH-44, leading towards Tamil Nadu. The suspects seem to be professionals, and we are coordinating with law enforcement agencies in Mysuru and Coimbatore to track them down,’ said ACP Ramesh Kumar of the Bengaluru Crime Branch. This incident marks the third major jewelry store robbery in the city within the last six months. Police urge citizens and shop owners in areas like Indiranagar, Jayanagar, and Whitefield to remain vigilant.”

Desired output:

I want to extract only the crime scene address: Shree Lakshmi Jewelers, MG Road, Bengaluru.

I have tried using JavaScript libraries like “compromise”, “wink-nlp”, “nlp.js”. However, these libraries only seem to detect US addresses correctly and fail to recognize Indian addresses.

I have also come across Python libraries like “spacy”.

Could anyone recommend the most efficient library or method for extracting addresses, especially for Indian addresses or a universal library ?

How to Fix ‘Untitled’ Appearing in Recent Chats in Firestore (Quasar App)?

Firestore Structure:

{
  "chatId": "abc123",
  "title": "Chat with AI",
  "messages": [{ "role": "user", "content": "Hello" }]
}

Code for fetching recent chats:

const chatsRef = collection(db, "conversations");
const q = query(chatsRef, orderBy("timestamp", "desc"), limit(3));

onSnapshot(q, (snapshot) => {
  recentChats.value = snapshot.docs.map(doc => ({
    id: doc.id,
    ...doc.data()
  }));
});

I’m building a Quasar-based chat app using Firebase Firestore. In my recent chats sidebar, the active chat moves to the center, and ‘Untitled’ appears for other recent chats. However, titles are stored correctly in Firestore. Why is this happening, and how can I fix it?

What could be causing the title issue, and how can I ensure recent chats display correctly?

How to run code isolated from the site context?

I am trying to build a chrome extension, I need to call a function from the isolated world to another script which is not in the sites context (like the background script for example). How should I go about this?

I tried calling the function inside the sites context, but for some reason when I fetch the websites api it requires the user to be logged out while other parts in my program require the user to be logged in.

react vite ( npm run build ) is Obfuscator the code? [closed]

I’m a beginner programmer in REACT with VITE and I noticed that when I type the command NPM RUN BUILD, the code is not like I would write in VS CODE. The code becomes encoded as if I used Obfuscator JS. Is it true that NPM RUN BUILD does a kind of Obfuscator for the code in addition to building it?

I even took the code after the NPM RUN BUILD and put the code on sites that make Obfuscators for JS and the code still worked even though it was a type of Obfuscator after I ran the NPM RUN BUILD.

I expected it to be like in VANILLA JS but no

Plotly + Knime + choroplethmap: how to put labels on top of regions?

I’m using Knime on a Mac, using Generic Javascript View. The code that I’m using:

var body = document.getElementsByTagName('body')[0];
var html = '<div id="myDiv">';
body.innerHTML = html;

var stateCoords = { 
    "opolskie": [17.9213, 50.6751],  
    "łódzkie": [19.4560, 51.7594]
};

var states = ["opolskie", "łódzkie"];

var data = [
  {
    type: "choroplethmap", 
    name: "asd", 
    geojson: "https://raw.githubusercontent.com/ppatrzyk/polska-geojson/master/wojewodztwa/wojewodztwa-min.geojson", 
    locations: states,
    z: [141, 140],  
    text: [ "test text1", "test text2" ],  // Labels for hover
    featureidkey: "properties.nazwa",
    colorbar: { title: 'Value' },
    zmin: 25, 
    zmax: 280, 
    colorscale: 'Viridis'
  },
  {
    type: 'scattergeo',
    geo: 'geo',  
    lon: states.map(state => stateCoords[state][1]), 
    lat: states.map(state => stateCoords[state][0]), 
    text: states,
    mode: 'text',
    textfont: {
        size: 14,
        color: 'black',
        weight: 'bold'
    }
  }
];

var layout = {
  map: {
    style: "light", 
    center: {lon: 19, lat: 52}, 
    zoom: 5.6
  },
  width: 1000, 
  height: 700, 
  margin: { t: 0, b: 0 }
};

Plotly.newPlot('myDiv', data, layout);

Which produces this (The label is only visible on hover):
The label is only visible on hover

What I’m after looks something like this:
enter image description here

Node configuration in Knime is this:
enter image description here

Clearly I’m not using scattergeo correctly, but it evades me what.

Script-generated SVGs in HTML page: Pros & Cons of DOM manipulation vs. “SVG code”

I want dozens of inline SVGs rendered, each with hundreds of uniform vertical lines: same colour, (scaled) width & start&end decoration/markers.
I use “problem domain” coordinates and specify transforms intending to keep processing in check; easy human interpretation a welcome bonus.

I managed to have concise SVG code generated, but on second thought, generating text to be interpreted feels indirect compared to manipulating DOM objects.

<svg style="background-color: #FFF;" width="300" height="180">
  <title>Bert Dobbelaere N9L25D7</title>
  <defs><marker id="dotB" markerWidth="4" markerHeight="4" refX="2" refY="2"><circle cx="2" cy="2" r="2" fill="black"></circle></marker></defs>
  <g stroke="black">
    <path stroke-width="0.05" d="M-.5 1m1-1v1m1-1v1m1-1v1m1-1v1m1-1v1m1-1v1m1-1v1m1-1v1m1-1v1"
     transform="matrix(0,20,333,0, 0,0)" /></g>
  <g marker-start="url(#dotB)" marker-mid="url(#dotB)" marker-end="url(#dotB)" stroke="black" fill="black" stroke-width="0.1">
    <path d="M0 1m0 0v6m.5-3v4m0-8v3m.5-1v3m1.7-5v7m.5-4v5m.5-6v2m0 1v1m1.7-5v2m0 4v1m0-4v1m.5-5v2m1.7 1v3m.5-5v3m0 1v2m1.7-1v2m0-5v2m0-5v1m.5 1v2m1.7 2v1m0-3v1m0-3v1m1.7 2v1m0-3v1m0-3v1"
     transform="scale(20)translate(0.75,0.5)" />
  </g>
</svg>

What are the pros and cons of EITHER

A) manipulating DOM objects   – OR –
1) generating SVG code?

Caching using eTag implementation

I’m trying to implement a caching system with eTags and I’m confused by the following behavior:

Method I

If I fetch the resource using the following approach, namely saving the eTag value and appending it for the subsequent requests:

headers =new Headers()
eTag && headers.set('If-None-Match',eTag)
fetch("http://localhost:3000/json", { "headers": headers }).then( r => r.headers.get('etag')).then(e => eTag = e);

I receive the following response:

enter image description here

The status code is 304, size is 181B, time is 11ms and the body is empty.

Method II

If I send the request like this, namely without the eTag value:

fetch("http://localhost:3000/json")

I receive the following response:

enter image description here

The status code, size and time are all the same, but this time the body is not empty.


If I proceed with the first method, I’ll also have to save the body in on the client-side, either in memory or inside local-storage and in case I receive a 304 response, I’ll have to get it from there, since there is no body.

If I go with the second method, I don’t have to save the body anywhere as I have it in the response object of the fetch method.

Since both methods have the same performance: size and time, what is the benefit of sending the eTag value here?
As a first impression, method 2 is much better because I don’t have to save the body locally anymore. I’m I missing something?

P.S: TThe browser I used is Chrome and the requests are sent to a simple Express server which has the following code:

import express from "express";
const app = express();

app.get("/json", (req, res) => { res.json({name:"Joe"}) });

app.listen(3000, () => {
  console.log(`Example app listening on port ${port}`);
});

How do I ignore events that have already been handled for keyboard shortcuts in javascript

When searching for a way to add keyboard shortcuts to websites I typically find solutions like this:

document.addEventListener('keyup', event => {
    if (event.key === 'f') {
        …
    }
});

However, this will trigger whenever an f is typed anywhere on the website, e.g. when typing into an <input> or <textarea> or when using typeahead in a <select>.

I could special-case all of these elements, but I would surely miss something.

Is there are generic way to ignore all of these and only trigger the shortcut when the keyboard event would not otherwise be handled?

How to dynamically change Bootstrap v5.3 primary color at runtime in Angular v17?

I am working on an Angular application that uses Bootstrap for styling. I want to allow users to select a theme color, and dynamically update the Bootstrap primary color (–bs-primary) at runtime without reloading the page.

Currently, Bootstrap’s primary color is defined in SCSS like this:

$primary: #0d6efd; 
@import "bootstrap/scss/bootstrap";

However, this approach requires recompilation, and I need a way to change the primary color dynamically via JavaScript or TypeScript.

What I Have Tried
CSS Variables
I attempted to override the Bootstrap primary color using CSS variables:

:root {
    --bs-primary: #ff5733; /* New color */
}

But this does not seem to work for all Bootstrap components like buttons and alerts.

Using JavaScript to Update Variables
I also tried updating CSS variables dynamically in TypeScript:

private changeThemeColor(color: string): void {
    document.documentElement.style.setProperty('--bs-primary', color);
}

However, this change does not reflect in Bootstrap components like

<span class="text-primary">Primary Text</span>
<button class="btn btn-primary">Primary Button</button>

How can I modify a component of a youtube iframe for accessibility?

I have an <iframe> with a youtube video, this video has a logo of the youtube channel and if you click it takes you to the channel, so far so good. But for accessibility reasons, when navigating by keyboard it should work in the same way when you press the ‘Enter’ key. And it doesn’t let me access to the component with the class .ytp-title-channel-logo to add a script that when you click enter it works as a click, I guess it’s a Youtube thing.

It’s html and JS.

Any suggestions?

This is the code I have at the moment:

(function () {
  const tag = document.createElement("script");
  tag.src = "https://www.youtube.com/iframe_api";
  const firstScriptTag = document.getElementsByTagName("script")[0];
  firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);

  window.addEventListener("load", () => {
    const iframe = document.getElementById("video2_youtube");

    try {
      const player = new YT.Player(iframe, {
        events: {
          onReady: (event) => {
            console.log("Player ready");
          },
          onError: (event) => {
            console.error("Error in the player:", event);
          },
        },
      });
      console.log(player.getIframe());
      console.log(player.getIframe().getElementsByTagName("body")); //dont show anything
    } catch (error) {
      console.error("Initialisation error:", error);
    }
  });
})();

I’ve tried using the Youtube API but I don’t know if I’m doing it right or not.

If I create the Player object from the API and use player.getIframe() it returns the iframe but doing a querySelector from a component inside doesn’t work. I understand that inside the iframe there is another DOM and that’s why I can’t select it from the JS.

If I access a div in javascript using querySelector, which contains heading,text-area,buttons.Does accesed div contain all the html elements in it?

/* HTML */
<div class="create-note">
   <h1 class = 'heading'>New Note</h1>
   <textarea name="" id="" placeholder="Enter your note..."></textarea>
   <button class = 'create-btn'>Create Note</button>
   <button class = 'close-btn'>Close</button>
</div>


/* CSS*/

.create-note {
  width: 441px;
  height: 316px;
  border: 1px solid #ccc;
  background-color: white;
  box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
  text-align: center;
  border-radius: 10px;
  position: absolute;
  top: 22%;
  left: 34%;
  display: none;
}

/* JavaScript */

let add_btn = document.querySelector('.add');
let container = document.querySelector('.container');
let createNote = document.querySelector('.create-note');
let close = document.querySelector('.close-btn');
add_btn.addEventListener('click', () => {
  createNote.style.display = 'block';
})

The display property of createNote is set to none, when i set the display of createNote to block using javascript, how does it display all the html elements inside it, when i selected only a div
My question is when we select an html block level element or container element using querySelector,getElementById etc , how does it contain all child elements?

Is Mongoose really an ORM, or is it something else?

I keep hearing people say that Mongoose is an ORM for MongoDB, but I thought ORMs are for relational databases like MySQL or PostgreSQL. Since MongoDB doesn’t use tables and rows but instead works with documents and collections, wouldn’t Mongoose be something different?

If Mongoose is not an ORM, what exactly is it? And how is it different from an ORM? Just trying to clear up my confusion. Thanks!

Use dhtmlx-gantt to dynamically calculate the width of the timeline column cells

How to dynamically set the cell width of the right time axis in dhtmlx-gantt, for example, set the cell width of the cell belonging to November to 40px, while the cell width of other months is 20px.enter image description here

I tried using the gantt.config.min_column_width configuration, but the width of the cells on the right will be uniformly changed. I want the effect to be differentiated between different months.