Webpack and babel can’t resolve TypeScript modules

I’m trying to import a module named Config from a services folder in my src directory, but I’m getting an error that the ./services/Config module can’t be found.

Here’s how I’m trying to import it:

import Config from './services/Config';

But if I import Config as ./services/Config.ts it works.

Module build failed (from ./node_modules/babel-loader/lib/index.js):
Error: Cannot find module './services/Config' from 'D:githubrepoNamesrc'

I’ve verified that the Config file exists in the services folder and that the services folder is in the same location as my index.js file.
tsconfig.json:

{
  "compilerOptions": {
    /* Basic Options */
    "target": "ES6", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', or 'ESNEXT'. */
    "module": "NodeNext", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', 'es2020', or 'ESNext'. */
    "lib": [
      "es2020",
      "DOM"
    ], /* Specify library files to be included in the compilation. */
    "allowJs": true, /* Allow javascript files to be compiled. */
    "resolveJsonModule": true,
    /* Basic Options */
    "declaration": true, /* Generates corresponding '.d.ts' file. */
    "emitDeclarationOnly": true, /* Generates '.d.ts' file only. */
    "isolatedModules": true, /* Transpile each file as a separate module (similar to 'ts.transpileModule'). */
    "outDir": "./dist", /* Redirect output structure to the directory. */
    /* Strict Type-Checking Options */
    "strict": true, /* Enable all strict type-checking options. */
    "noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */
    "strictNullChecks": true, /* Enable strict null checks. */
    "strictFunctionTypes": true, /* Enable strict checking of function types. */
    "strictBindCallApply": true, /* Enable strict 'bind', 'call', and 'apply' methods on functions. */
    "strictPropertyInitialization": true, /* Enable strict checking of property initialization in classes. */
    "noImplicitThis": true, /* Raise error on 'this' expressions with an implied 'any' type. */
    "alwaysStrict": true, /* Parse in strict mode and emit "use strict" for each source file. */
    /* Additional Checks */
    "noUnusedLocals": true, /* Report errors on unused locals. */
    "noUnusedParameters": true, /* Report errors on unused parameters. */
    "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */
    "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */
    /* Module Resolution Options */
    "moduleResolution": "NodeNext", /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */
    "baseUrl": "./", /* Base directory to resolve non-absolute module names. */
    "esModuleInterop": true, /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */
  },
  "include": [
    "src/**/*",
  ],
  "exclude": [
    "./node_modules"
  ],
}

webpack.config.js:

const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const CopyWebpackPlugin = require('copy-webpack-plugin');
//const { PyodidePlugin } = require("@pyodide/webpack-plugin");
const webpack = require('webpack');
const fs = require('fs'); // to check if the file exists
const dotenv = require('dotenv');
const TerserPlugin = require("terser-webpack-plugin");
const WebpackObfuscator = require('webpack-obfuscator');


module.exports = (env) => {
    const currentPath = path.join(__dirname);
    const basePath = currentPath + '/.env';
    const envPath = basePath + '.' + env.ENVIRONMENT;
    const finalPath = fs.existsSync(envPath) ? envPath : basePath;
    const fileEnv = dotenv.config({ path: finalPath }).parsed;

    const envKeys = Object.keys(fileEnv).reduce((prev, next) => {
        prev[`process.env.${next}`] = JSON.stringify(fileEnv[next]);
        return prev;
      }, {});
    
    return {
        entry: path.join(__dirname, 'src', 'index.js'),
        optimization: {
            minimize: true,
            minimizer: [
                new TerserPlugin({
                    test: /.js(?.*)?$/i,
                }),
            ],
        },
        output: {
            path: path.resolve(__dirname, "dist"),
            filename: "index.js",
        },
        mode: "development",
        module: {
            rules: [
                {
                    test: /.(js|jsx)$/,
                    use: "babel-loader",
                    exclude: /node_modules/,
                },
                {
                    test: /.css$/,
                    use: ['style-loader', 'css-loader']
                },
                {
                    test: /.(ts|tsx)$/,
                    exclude: /node_modules/,
                    use: {
                    loader: "ts-loader",
                    },
                },            
                {
                    test: /.(woff(2)?|ttf|eot|png|svg|jpg|gif)(?v=d+.d+.d+)?$/,
                    use: [
                    {
                        loader: "file-loader",
                        options: {
                        name: "[name].[hash:8].[ext]",
                        outputPath: "assets/",
                        },
                    },
                    ],
                },
                {
                    test: /.s[ac]ss$/i,
                    use: [
                    // Creates `style` nodes from JS strings
                    "style-loader",
                    // Translates CSS into CommonJS
                    "css-loader",
                    // Compiles Sass to CSS
                    "sass-loader",
                    ],
                },
                {
                    test: /.js$/,
                    enforce: 'post',
                    use: {
                        loader: WebpackObfuscator.loader,
                        options: {
                            rotateStringArray: true

                        }
                    },
                    include: [
                        path.resolve(__dirname, 'src/stores/SimulationStore.js'),
                        path.resolve(__dirname, 'src/stores/MapStore.js'),
                        path.resolve(__dirname, 'src/stores/DevprojectsStore.js'),
                        path.resolve(__dirname, 'src/stores/SimulationResultsStore/SimulationResultsStore.js'),
                        path.resolve(__dirname, 'src/stores/AmenitiesStore.js'),
                        path.resolve(__dirname, 'src/services/market_equilibrium_simulator.js'),
                    ]
                }
            ]
        },
        plugins: [
        //new PyodidePlugin(),
            new HtmlWebpackPlugin({
                template: path.join(__dirname, 'src', 'index.html')
            }),
            new webpack.DefinePlugin(envKeys),
            // new CopyWebpackPlugin({
            //    patterns: [{ from: 'public' }]
            // }),
        ],
        resolve: {
            alias: {
                "@": path.resolve(__dirname, "src/"),
            },
            extensions: [".js", ".jsx", ".ts", ".tsx"],
        },
        devServer: {
            historyApiFallback: true,
            port: 3001,
            open: true,
            // host: '192.168.0.142',//your ip address
            // port: 3001,
            // disableHostCheck: true
        allowedHosts: 'all'
        }
    }
};

.babelrc:

{
    "presets": ["@babel/env", "@babel/react", "@babel/preset-typescript"],
    "plugins": [
        ["@babel/plugin-proposal-decorators", { "legacy": true }],
        ["@babel/plugin-proposal-class-properties", { "loose": false }],
        // In contrast to MobX 4/5, "loose" must be false!    ^
        ["babel-plugin-inline-json", {}]
    ]
}

.babel.config.js:

module.exports = {
    presets: [['@babel/preset-env', { targets: { node: 'current' } }], "@babel/preset-typescript"],
    plugins: [['@babel/plugin-proposal-decorators', { legacy: true }]]
};

TypeError: require is not a function( koa dependent formidable package error)

The formidable package version which is installed in the node-modules is 1.2.2 and the package.json has following packages:

"koa": "2.6.2",
"koa-bodyparser": "4.2.0",
"koa-compress": "5.1.1",
"koa-helmet": "4.0.0",
"koa-router": "7.4.0"

I integrated “koa-body” for handling multipart file uploads. However, upon launching the application, I encountered the below error. Since my application is quite dated and utilizes older koa-related packages, I opted for version 4.0.7 of koa-body as it seemed more appropriate.

Can anyone help what could be the fix for this issue?

Note: Application node version is 18

/Users/vinay/final-stories/stories/node_modules/formidable/lib/incoming_form.js:3

var crypto = require(‘crypto’);

TypeError: require is not a function

at Object…/../node_modules/formidable/lib/incoming_form.js (/Users/vinay/final-stories/stories/node_modules/formidable/lib/incoming_form.js:3:1)
at webpack_require (/Users/vinay/final-stories/stories/applications/stories-service/build/webpack/bootstrap:685:1)
at fn (/Users/vinay/final-stories/stories/applications/stories-service/build/webpack/bootstrap:59:1)
at Object…/../node_modules/formidable/lib/index.js (/Users/vinay/final-stories/stories/node_modules/formidable/lib/index.js:1:20)
at webpack_require (/Users/vinay/final-stories/stories/applications/stories-service/build/webpack/bootstrap:685:1)
at fn (/Users/vinay/final-stories/stories/applications/stories-service/build/webpack/bootstrap:59:1)
at Object…/../node_modules/koa-body/index.js (/Users/vinay/final-stories/stories/node_modules/koa-body/index.js:18:15)
at webpack_require (/Users/vinay/final-stories/stories/applications/stories-service/build/webpack/bootstrap:685:1)
at fn (/Users/vinay/final-stories/stories/applications/stories-service/build/webpack/bootstrap:59:1)
at Object…/node-service/bodyParsers/jsonBodyParser.ts (/Users/vinay/final-stories/stories/applications/node-service/bodyParsers/jsonBodyParser.ts:2:1)
[nodemon] app crashed – waiting for file changes before starting…

I want the application to start without any errors. So that I can test file upload

How can I use Python to encode a string into JavaScript-safe quoting? [duplicate]

I have Python code which generates JavaScript, and I’d like it do so something like:

print(f"alert('Hello {username}!');n")

The problem is, of course, what happens if username == "Fred O'Malley". This is not only a bug, but a likely vulnerability.

I could use a regex to catch that, but there would of course be other more complicated vectors. Hence, I need a comprehensive solution.

Nest js / node js file upload with multer: Pass a file stream to function handler

Multer gets a file from the request in a readable stream, and with default engines, we can save the file on disk or in RAM. After that, it’s accessible in a file object that goes to the route handler. In my case, I want to upload the file to S3, so I need access to the stream, but there is no way of getting that in the handler function.

This issue describes how to solve it by creating a custom engine or using a library: https://github.com/aws/aws-sdk-js-v3/issues/5479.

And this is a working solution, but I don’t like that I have to pass a custom engine in the decorator. I’m working on a Nest.js app, and I have a separate module and class to work with AWS S3, which has its own dependencies. As I’m having to pass a custom engine in the decorator, it means I have to recreate all dependencies, which is not the Nest way of doing things.

I have tried to develop a custom engine and was looking for a configuration options – nothing.

I’m looking for a way to pass a readable stream to the handler. Answering ahead – saving on disk, creating a readable stream, and deleting the file is not an option.

Vite and WordPress for VSC remote development

If I understand correctly, Vite is used primarily for local development. I’ve set it up using xampp and it works just fine on localhost inculding hot module replacement, browsersync etc

Despite our best efforts we came to the conclusion that local development just doesn’t work for our team.

Can Vite be configured so it runs on a remote server, for example instead of your having a wordpress installation locally we host it on http://mydevsite.dev.com ?

I’m using a wordpress theme https://github.com/oguilleux/vite-wordpress-starter-theme and I’ve changed js-css.php to

default server address, port, and entry point can be customized in vite.config.js
define( ‘VITE_SERVER’, get_template_directory_uri() );

The only way I got it to work is by using npm run build which works fine but takes 5-10 seconds and after it builds the script stops. Another workaround is using npm run build — –watch which keeps the terminal alive but it takes way too long on each save.

I’ve also tried changing viteconfig following this thread VSC Remote Server Works with Vite projects? but none of the solutions worked.

am I completely missing the point of vite or do I just struggle to make it work remotely?

Custom Scrollbar using div

So what i`m trying to achieve is custom scrollbar with same behavior as default one, but this scrollbar should not take space at all, so z-index and position absolute.

but i’m not sure how to implement it so it will display scroll progress as default one

so i have this template

document.addEventListener('DOMContentLoaded', function() {
  const scrollContainer = document.querySelector('.scroll');
  const customScrollbar = document.querySelector('.scrollbar');



  scrollContainer.addEventListener('scroll', function() {
    const scrollHeight = scrollContainer.scrollHeight - scrollContainer.clientHeight;
    console.log(scrollContainer.scrollTop);
    const scrollTop = scrollContainer.scrollTop;
    const scrollPercentage = (scrollTop / scrollHeight) * 100;


    customScrollbar.style.top = `${scrollPercentage}%`;
  });
});
.scroll {
  display: flex;
  flex-direction: column;
  height: 200px;
  width: 200px;
  overflow-y: auto;
  position: relative;
}

.scrollbar {
  position: absolute;
  right: 0;
  top: 0;
  height: 10px;
  width: 10px;
  background: red;
}

.scroll::-webkit-scrollbar {
  display: none;
}

.scroll {
  scrollbar-width: none;
}

.scroll::-ms-scrollbar {
  display: none;
}
<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <div class="scroll">
    <div class="scrollbar"></div>
    <a>bbbbb</a>
    <a>bbbbb</a>
    <a>bbbbb</a>
    <a>bbbbb</a>
    <a>bbbbb</a>
    <a>bbbbb</a>
    <a>bbbbb</a>
    <a>bbbbb</a>
    <a>aaaaa</a>
    <a>bbbbb</a>
    <a>bbbbb</a>
    <a>bbbbb</a>
    <a>bbbbb</a>
    <a>bbbbb</a>
    <a>bbbbb</a>
    <a>bbbbb</a>
    <a>bbbbb</a>
    <a>bbbbb</a>
    <a>bbbbb</a>
    <a>bbbbb</a>
    <a>bbbbb</a>
    <a>bbbbb</a>
    <a>bbbbb</a>
    <a>bbbbb</a>

  </div>
</body>

</html>

ps: overflow:overlay; is not possible for me because i’m making desktop app and this feature there is not supported at all, and custom js libraries like overlay-scrollbars are not suitable for me too i guess, but feel free to provide some ideas or code 🙂

How can I convert my Thymeleaf model attribute to a JavaScript element?

I add this element to the Thymleaf model:

  List<Player> allGamePlayers = playerRepository.findGamePlayers(gameFromDb.get().getHomeTeam().getId(), gameFromDb.get().getAwayTeam().getId());
            model.addAttribute("allGamePlayers", allGamePlayers);

Now I have a selection with options with all the players put into

 <div id="scorersContainer">
    <select name="scorers" multiple>
         <option th:each="player: ${allGamePlayers}" th:value="${player.getId()}"
            th:text="${player.getName()}"></option>
   </select>
</div>

Then I have a button which activates the JavaScript function to add another select with options

 <button type="button" onclick="addGoal()">Add Goal</button>

The gamePlayers should be converted to a javascript element but it seems like it’s not working. Cause when I click the button a new select element appears but there are no options inside it.

 <script>
        /*<![CDATA[*/

        var allGamePlayers = /*[[${allGamePlayers}]]*/ [];    /*]]>*/

        function addGoal() {
            var container = document.getElementById("scorersContainer");
            var selectElement = document.createElement("select");
            selectElement.setAttribute("name", "scorers");
            selectElement.setAttribute("multiple", "");


            allGamePlayers.forEach(function (player) {
                var option = document.createElement("option");
                option.setAttribute("value", player.id);
                option.textContent = player.name;
                selectElement.appendChild(option);
            });

            container.appendChild(selectElement);
        }
    </script>

How can I solve this problem? Maybe the players aren’t converted correctly to the variable?

How to execute javascript in a secondary browser window with an external website in electronjs?

I am an electronjs/nodejs beginner and creating a project using electron-vite (vite+react+electron) to explore and learn more about it. I am already comfortable with vite+react.

The project that I am building is a bookmark app or could be a bookmark app.

I have a button that opens a popup modal. Inside the modal, there is a form with an input field (type URL) and a submit button, users can enter a URL and press submit. This URL is then processed by electron APIs and returns an object containing the page title, and a screenshot of the page which I display in UI. This is all happening with the help of IPC communication. Upon successful URL page fetching, the popup gets closed and the object containing the page title and the screenshot is displayed in the UI.

Now when I double clicks the bookmark card, A secondary windows open with the external URL for example https://github.com

// open external content url in new window const openURLInNewWindow = (url) => { const readUrl = window.open( url, '',
maxWidth=2000;
maxHeight=2000
width=1200;
height=800;
contextIsolation=1;
nodeIntegration=0;
`
)

}`

Now, at this point, I want to write some javascript for this new window with external URL but unable to achieve this after many tries including eval.

I want to ask how to achieve this and is this a good practice? I want to create a fixed positioned button in the external window and do some further action action upon clicking it.

Let me know if you need to see any code in any file.

Thank you for any help

My Code Repository: https://github.com/HamzaAnwar1998/bookmark-app

I tried eval method by changing the html meta tag and allowing unsafe-eval but I don’t want to use it and it also freezes the electron app when I execute alert(“Hello”) in the external website window, I don’t know why.

I want to execute javascript in the external website window. I want to create a fixed positioned button in the external website and perform further action when clicked on it

MediaRecorder (JS) not working on webkit web browsers when deployed, locally and on Chromium it is working fine either way

I have a flask app that is deployed using Caddy and Gunicorn. I use the MediaRecorder JS libary to record the microphone of a user and afterwards send it to GPT. This works awesome on Chromium and Webkit browsers when I have a local server on my computer. But when i deploy the project to my VPS using Caddy and Gunicorn it does not work as supposed on only webkit browsers. Sometimes it detects the first word and other times it detects nothing. I will attach my JS code that uses MediaRecorder and some pictures when run locally and when I run it using my VPS.

Here is the JS code


recordButton.addEventListener('click', async () => {
    if (!isRecording) {
        isRecording = true;
        recordButton.innerText = 'Stoppa inspelning';
        await startRecording();
    } else {
        isRecording = false;
        recordButton.innerText = 'Starta inspelning';
        await stopRecording();
    }
});

async function startRecording() {
    const stream = await navigator.mediaDevices.getUserMedia({ audio: true });
    mediaRecorder = new MediaRecorder(stream);
    mediaRecorder.addEventListener('dataavailable', (event) => {
        audioChunks.push(event.data);
    });
    mediaRecorder.start();
    statusElement.textContent = 'Spelar just nu in...';
}


function stopRecording() {
    return new Promise(resolve => {
        mediaRecorder.addEventListener('stop', async () => {
            statusElement.textContent = 'Inspelning avslutad.';
            const audioBlob = new Blob(audioChunks);
            audioChunks = [];
            const formData = new FormData();
            formData.append('audio', audioBlob);

            fetch('/update_button', {
                method: 'POST',
                headers: {
                    'Content-Type': 'application/json',
                },
                body: JSON.stringify({
                    buttonValue: button_value,
                }),
            });

            console.log('Button value:', button_value);

            const response = await fetch('/transcribe', {
                method: 'POST',
                body:
                    formData,
            });
            const { transcription, answer } = await response.json();

            responseElement.textContent = 'User input: ' + transcription;
            answerElement.textContent = 'GPT answer: ' + answer;


            resolve();
        });


        mediaRecorder.stop();
    });
}

Here is a picture of a correct output when I run the project locally (using webkit browser – I always use the same input)
Here is the image via imgur

Here is a picture of a faulty output when the project is deployed via my VPS (using webkit browser – I always use the same input)
Here is the image via imgur

I want to add that I do not get any errors on the server side or client side.

I have tried restarting the VPS, I have tried updated all my python libraries, I have tried different devices (mobile and desktop). All i found was that the project does not work on webkit browser but only when deployed. Locally everything works fine.

Changing the color of points in Highcharts using series.states.select.color

I have a map I created using the Highcharts map module. I am trying to make it so that when you select a point, it changes color and then returns to its original color when no longer selected. Despite following the API documentation (https://api.highcharts.com/highmaps/plotOptions.series.states.select.color) I can only get the point to change to the default select settings – grey fill with a black border.

This is the code for the chart:

(async () => {

    const topology = await fetch(
        'https://code.highcharts.com/mapdata/custom/europe.topo.json'
    ).then(response => response.json());

    Highcharts.mapChart('container', {
        chart: {
            map: topology,
            margin: 0,
            backgroundColor: '#fff'
        },

        title: {
            text: ''
        },
      
        tooltip: {
          headerFormat: '',
          pointFormat: '{point.name}',
          backgroundColor: '#333',
          borderColor: '#333',
          borderRadius: 0,
          shadow: false,
          shape: 'rect',
          padding: 8,
            style: {
              fontSize: '1em',
              fontWeight: 'normal',
              color: '#fff'
          },
        },
      
        legend: {
          enabled: false,
        },
      
        plotOptions: {
            mappoint: {
              allowPointSelect: true,
            states: {
              select: {
                color: 'red'
              }
            },
              dataLabels: {
                enabled: false
                  }
                }
            },
            mapView: {
              projection: {
                name: 'WebMercator'
                },
              zoom: 5.1,
              center: [4, 52]
            },
      
        series: [{
            name: 'Basemap',
            borderColor: '#d3d3d3',
            borderWidth: 1,
            nullColor: '#fff',
        }, {
            type: 'mappoint',
            marker: {
              symbol: 'circ',
              radius: 6,
            },
            name: 'P',
            cursor: 'pointer',
            data: [{
                name: 'P1',
                lat: 49.214439,
                lon: -2.131250,
            },{
                name: 'P2',
                lat: 51.4811,
                lon: -0.6248,
            },{
                name: 'P3',
                lat: 50.7932,
                lon: -1.8843,
            },{
                name: 'Winchcombe Place Care Home',
                lat: 51.4090,
                lon: -1.3215,
            },{
                name: 'P4',
                lat: 53.9320,
                lon: -1.0694,
            }],
        },{
            type: 'mappoint',
            marker: {
              symbol: 'circ',
              radius: 6,
            },
            name: 'S',
            cursor: 'pointer',
            data: [{
                name: 'S1',
                lat: 56.2639,
                lon: 9.5018,
            },{
                name: 'S2',
                lat: 51.2977,
                lon: -0.3079,
            },{
                name: 'S3',
                lat: 51.3725,
                lon: -0.4635,
            }],
        }]
    });

})();

I have tried changing the state in the individual series’ sections and also using a point event instead, but no matter what happens, the point always changes to grey with a black border on the first click. I even asked the Highcharts GPT tool and the corrected code it gave me produced exactly the same results. What am I missing?

This is the codepen for the full chart:

Codepen

Unhandled Runtime Error Error: Objects are not valid as a React child even if i’m passing down a string

i’m building the frontend of an app using React.
There’s an error however that i’m losing my mind over.

Unhandled Runtime Error

Error: Objects are not valid as a React child (found: object with keys {params, searchParams}). If you meant to render a collection of children, use an array instead.

the problem is that i’m passing to the othher components in the props a String as you can see down in the code:

 import React, { useState, useEffect } from "react";
 import { useRouter } from "next/navigation";
 import Checkout from "../Checkout/page";


export function Model({object}:{object: Object}){
let arrayFromObj: any[] = []
arrayFromObj = Object.values(object);
const router = useRouter();
function handleClick(){
    router.push('/Checkout');
    let string: string = arrayFromObj[0];

    
    
    Checkout(string);
}

return(
    <div className="containerModal" id="modal">
        <center>
            <img src={arrayFromObj[1]} alt={arrayFromObj[0]} style={{border: "1px solid white", boxShadow: "0 0 15px #fff"}}></img>
            <h1>{arrayFromObj[1]}</h1>
            <p>Descrizione: {arrayFromObj[4]}</p>
            <p>Prezzo: {arrayFromObj[3]}</p>
            <p>Proprietario: {arrayFromObj[5]}</p>
            <p>Caricato il: {arrayFromObj[2]}</p>
            <p>Disponibilità: {arrayFromObj[6]}</p>
        </center>
        <button type="button" className="button" id="button" onClick={handleClick}>
            Acquista questo prodotto
        </button>
    </div>
)
}

this is the child component code:

import React from "react";

const Checkout = (name: string)=>{
     return <h1>{name}</h1>
 }
 export default Checkout

What am i doing wrong? Why am i getting this error?

Please help me, why Google PageSpeed Insights shows ‘Client-side redirect’ for my domain, which has a Google selected canonical URL

Screenshot of Google PageSpeed Insights displaying the ‘Client-side redirect
My website is multilingual. When I check the page speed of specific URLs like ‘https://www.example.com/de/’ using Google PageSpeed Insights, it shows ‘Client-side redirect’ for the page ‘https://www.example.com/en/’. This problem persists across all pages, including:

All these pages are being deindexed, with the problem indicated as ‘Page with redirect,’ despite no actual redirection being implemented.

How to style td on server side datable

I have my below code for server side processing using datatable and it is working well.

Am getting the data to my html from my server side script and everything is ok

My problem is: How can I style <td> for the returned data, like:

<td><a href=""> returned data column 4 value goes here </a></td>
<td><i class="fa fa-user-circle-o"></i> returned data column 2 value goes here</td>

output from the server side script

{
  "draw": "iTotalRecords",
  "1": null,
  "data": [
    [
      "456777",
      "Jane",
      "USA",
      "Link",
      1],
  ]
}

My html looks like this

<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="utf-8" />
        <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" />
        <title>DataTables</title>

        <!-- DataTables CSS library -->
        <link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/1.11.3/css/jquery.dataTables.min.css" />

        <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" />

        <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>

        <!-- DataTables JS library -->
        <script type="text/javascript" src="https://cdn.datatables.net/1.11.3/js/jquery.dataTables.min.js"></script>

        
    </head>
    <body>
        <div class="container">
            <table id="datable">
                <thead>
                    <tr>
                        <th></th>
                        <th></th>
                        <th></th>
                        <th></th>                    
                    </tr>
                </thead>
            </table>
        </div>
    
    <script type="text/javascript">
        $(document).ready(function () {
            $("#datable").dataTable({
               "processing": true,
               "serverSide": true,
               "ajax": {
               "url": "jjj.php",
               "type": "POST",
               "dataType":"json"
              },
            });
        });
    </script>
    </body>
</html>

firebase.firestore is not a unction

when i sign up on my sign up page it stores details in the data base but still shows one error saying firebaseApp.firestore is not a function

here is the code for the sign-up

import { useState, useContext, useEffect} from "react"
import { Link, useNavigate} from "react-router-dom"
import { FirebaseContext } from "../context/firebase"
import * as ROUTES from '../constants/routes'
import { doesUsernameExist } from "../services/firebase";
import { firebaseApp } from "../lib/firebase";

import { getAuth, createUserWithEmailAndPassword, updateProfile } from "firebase/auth"


export default function Signup() {
    const navigate = useNavigate(); 
    // eslint-disable-next-line no-unused-vars
    const { firebase } = useContext(FirebaseContext);

    const [ username, setUsername] = useState('')
    const [ fullname, setFullname] = useState('')

    const [ emailAddress, setEmailAddress] = useState('')
    const [ password, setPassword] = useState('')


    const [ error, setError] = useState('')
    const isInvalid = password === '' || emailAddress === ''

   const handleSignup =async (event) => {
      event.preventDefault()

   const usernameExists = await doesUsernameExist(username);

   if (!usernameExists) {
    try {
      const auth = getAuth();
      const createdUserResult = await createUserWithEmailAndPassword(auth, emailAddress, password);
      await updateProfile(createdUserResult.user, {
        displayName: username,
      });

        // firebase user collection (create a document)
        await firebaseApp.firestore().collection("users").add({
          userId: createdUserResult.user.uid,
          username: username.toLowerCase(),
          fullname,
          emailAddress: emailAddress.toLowerCase(),
          following: [],
          dateCreated: Date.now(),
        });

        navigate.push(ROUTES.DASHBOARD);
      } catch (error) {
          setFullname('');
          setEmailAddress('');
          setPassword('');
          setError(error.message);
        }
      } else {
        setError('That username is already taken, please try another.');
        }
      }

   useEffect(() => {
     document.title = 'Sign Up - Instagram'
   }, []);

    return (
        <div className="container mx-auto max-w-screen-md h-screen flex flex-col md:flex-row items-center">
            <div className="flex justify-center md:w-2/5">
                <img 
                    src="/images/iphone-with-profile.jpg" 
                    alt="iphone with Instagram app" 
                    className="w-full"
                />
            </div>
            <div className="md:w-3/5 md:mx-auto">
                <div className="flex flex-col items-center bg-white p-4 border border-gray-primary mb-4 rounded">
                    <h1 className="flex justify-center w-full">
                        <img src="/images/logo.png" alt="instagram" className="mt-2 w-6/12 mb-4"/>
                    </h1>
                    {error && <p className ="mb-4 text-xs text-red-primary">{error}</p>}
                    <form onSubmit={handleSignup} method="POST">
                        <input 
                            aria-label="Enter your username"
                            type="text"
                            placeholder="username"
                            className="text-sm text-gray-base w-full py-5 px-4 h-2 border-gray-primary rounded mb-2"
                            onChange={({ target }) => setUsername(target.value)}
                            value={username}
                        />
                        <input 
                            aria-label="Enter your fullname"
                            type="text"
                            placeholder="Full Name"
                            className="text-sm text-gray-base w-full py-5 px-4 h-2 border-gray-primary rounded mb-2"
                            onChange={({ target }) => setFullname(target.value)}
                            value={fullname}
                        />
                        <input 
                            aria-label="Enter your email address"
                            type="text"
                            placeholder="Email address"
                            className="text-sm text-gray-base w-full py-5 px-4 h-2 border-gray-primary rounded mb-2"
                            onChange={({ target }) => setEmailAddress(target.value)}
                            value={emailAddress}
                        />
                        <input 
                            aria-label="Enter your password"
                            type="password"
                            placeholder="password"
                            className="text-sm text-gray-base w-full py-5 px-4 h-2 border-gray-primary rounded mb-2"
                            onChange={({ target }) => setPassword(target.value)}
                            value={password}
                        />
                        <button
                            disabled={isInvalid}
                            type="submit"
                            className={`bg-blue-medium text-white w-full rounded h-8 font-bold ${isInvalid && 'opacity-50'}`}
                        >
                            Sign Up
                        </button>
                    </form>
                </div>
                <div className="flex justify-center items-center flex-col w-full bg-white p-4 rounded border border-gray-primary">
                    <p className="text-sm">Already have an account?{' '}
                        <Link to={ROUTES.LOGIN} className="font-bold text-blue-medium">
                            Login
                        </Link>
                    </p>
                </div>
            </div>
        </div>
    )
}

the sign up page after signing is supposed to take me to the timeline where i can follow people and like their pictures so i need this ti take me straight to the timeline

fslightbox: Disable buttons on first and last gallery item

I just implemented fslightbox into my HTML. I want to disable the previous button on the frist item of the gallery and the next button on the last item.

I have no idea how to do this. Has anyone of your some experience with this plugin?

As I have nearly no experience with JS, I asked ChatGPT, but its answer did not work.

<script>
  const lightbox = new FsLightbox();

  lightbox.props.beforeShow = (slide, props) => {
    if (slide === 0) {
      // Hide the previous button on the first image
      props.ui.prevButton.style.display = 'none';
    } else {
      // Show the previous button on other slides
      props.ui.prevButton.style.display = '';
    }

    if (slide === props.sources.length - 1) {
      // Hide the next button on the last image
      props.ui.nextButton.style.display = 'none';
    } else {
      // Show the next button on other slides
      props.ui.nextButton.style.display = '';
    }
  };
</script>