JS Injection to Flutter via WebView

My question is regarding injecting Javascript into flutter by using WebView. Initially, this was my JS script, it doesn’t return everything under the selector, part of the page is missing. However, when I check on the inspect element, the missing ‘part’ of the page is under the same selector.

 WebView(
    initialUrl: widget.url,
    javascriptMode: JavascriptMode.unrestricted,
    onWebViewCreated: (WebViewController webViewController) {
      _controller = webViewController;
    },
    onPageFinished: (String url) async {
      try {
        // Inject JavaScript to keep only the desired element, for example, a <div> with a class or id
        await _controller.runJavascript("""
  
var siteContent = querySelector('site-content'); // Replace with the actual selector
document.body.innerHTML=""
document.body.append(siteContent)
var sideBar = document.querySelector('.main-sidebar'); // Replace with the actual selector
sideBar.remove()
 """);

        setState(() {
          isLoaded = true;
        });
      } catch (e) {
        setState(() {
          isLoaded = true;
        });

        print(e);
      }
    },
  ),

Then I saw one suggestion to add a return in the JS code, I managed to get the whole HTML page BUT it skips the rest of the JS script, like the .append and .remove statement.

Does anyone know why does the return statement skips the remaining of the JS script? Thank you!

How to sort my array by length of its keys array in javascript?

How to sort my array by length of its keys array in javascript ?

my_array = [];
my_array['a'] = ['val1', 'val2'];
my_array['b'] = ['val1', 'val2', 'val3'];
my_array['c'] = ['val1', 'val2'];
my_array['d'] = ['val1', 'val2', 'val3'];
my_array['e'] = ['val1'];

sort my_array should result :-

my_array [
    'e' => ['val1'],
    'a' => ['val1', 'val2'],
    'c' => ['val1', 'val2'],
    'b' => ['val1', 'val2', 'val3'],
    'd' => ['val1', 'val2', 'val3']
];

Edit :-
My original code is :

var rows = JSON.parse('my_json_string');
let my_array =[]; 

for( let x=0; x<rows.length; x++ )
{ 
    if( Array.isArray( my_array[ rows[x].rowName ] ) )
    {
        my_array[ rows[x].rowName ].push( rows[x].rowValue );
    }else{
        my_array[ rows[x].rowName ] = [ rows[x].rowValue ]; 
    }
} 

How to download file directly to disk storage? [closed]


Most of the time, I use one of the following approaches to download a file:

  1. Direct Download Using an Anchor Tag (<a>):

    I can create a direct download link using an HTML anchor (<a>) tag with the href attribute pointing to the file’s URL. For example:

    <a href="https://example.com/files/ask.pdf" download>Download File</a>
    

    In this case, the file is hosted on a public server (e.g., https://example.com/files/ask.pdf), and when I click the link, the browser handles the file download process. The download attribute ensures that the file is downloaded instead of being opened in the browser.

    This method relies on the browser to manage the file streaming and saving process. It is simple and works well for publicly accessible files.

  2. Using Blob for Dynamic File Downloads:

    If the file needs to be generated dynamically or is not publicly accessible, I can use JavaScript with the Blob API to create and trigger the download programmatically. Here’s an example:

    // Example: Dynamically creating and downloading a PDF file
    const fileContent = "This is the content of the file."; // Replace with actual file data
    const blob = new Blob([fileContent], { type: 'application/pdf' });
    
    // Create a temporary URL for the Blob
    const url = window.URL.createObjectURL(blob);
    
    // Create a temporary <a> element to trigger the download
    const a = document.createElement('a');
    a.href = url;
    a.download = 'ask.pdf'; // Specify the filename
    document.body.appendChild(a); // Append to the DOM
    a.click(); // Trigger the download
    
    // Clean up
    document.body.removeChild(a);
    window.URL.revokeObjectURL(url);
    

Besides this, I watched the Telegram web app using another approach. I have conducted some research, but I did not understand how this actually works. I want to know how to do this.

When you press the file you want to download in Telegram, it initiates the download. As you can see in the image below Screenshot, the progress in both the app and the download is the same. My big question is, how is this even possible? I mean, what type of download techniques are used? I have tried to see the source code at https://github.com/morethanwords/tweb/tree/master/src/lib/files, but I did not quite understand it.

How to resolve MinIO connection issues when deploying on Render Cloud using Ngrok?

I’m working on the deployment of my backend app, which has been developed using Node/Express, MongoDB, and MinIO. During development, I used the MinIO connection locally without any issues. However, when deploying the app on Render Cloud, I encountered an error stating that the MinIO port does not have access to a public URL.

To resolve this, I used Ngrok to expose the local port to a public URL. While this worked partially, I started getting the following errors:

Error: connect ENETUNREACH 2600:1f1c:d8:5f00::6e:2:9000 – Local (:::0)
Error: connect ETIMEDOUT 13.56.217.111:9000
Error: connect ENETUNREACH 2600:1f1c:d8:5f00::6e:0:9000 – Local (:::0)

Below is the relevant Ngrok session information and MinIO configuration:

 #ngrok - m my ngrok commands and the forwarded urls                                                                                                                                                                                     
                                                                                                                                                                                                             
 ❤️  ngrok? We're hiring https://ngrok.com/careers                                                                                                                                                            
                                                                                                                                                                                                             
 Session Status                online                                                                                                                                                                        
 Account                       [email protected] (Plan: Free)                                                                                                                                   
 Version                       3.19.1                                                                                                                                                                        
 Region                        India (in)                                                                                                                                                                    
 Latency                       290ms                                                                                                                                                                         
 Web Interface                 http://127.0.0.1:4040                                                                                                                                                         
 Forwarding                    https://d081-2409-40e3-5e-2bc0-bc90-7a48-347a-3471.ngrok-free.app -> http://localhost:9000                                                                                    
                                                                                                                                                                                                             
 Connections                   ttl     opn     rt1     rt5     p50     p90                                                                                                                                   
                               0       0       0.00    0.00    0.00    0.00                                                                                                                                  
                                                                              
 
 
 #minio.Confog.js - Minio configuration files
 
 const Minio = require("minio");
 const dotenv = require("dotenv");
 
 dotenv.config({ path: "./config.env" });
 
 const minioClient = new Minio.Client({
   endPoint: process.env.MINIO_ENDPOINT.replace("https://", "").replace("/", ""), 
   port: parseInt(process.env.MINIO_PORT, 10) || 443, 
   useSSL: true,
   accessKey: process.env.MINIO_ACCESS_KEY,
   secretKey: process.env.MINIO_SECRET_KEY,
 });
 
 const bucketName = process.env.MINIO_BUCKET;
 
 (async () => {
   try {
     const exists = await minioClient.bucketExists(bucketName);
     if (!exists) {
       await minioClient.makeBucket(bucketName, "");
       console.log(`Bucket '${bucketName}' created successfully.`);
     } else {
       console.log(`Bucket '${bucketName}' already exists.`);
     }
   } catch (err) {
     console.error("Error with MinIO bucket:", err);
   }
 })();
 
 module.exports = minioClient;
 
 
 
 
 # Environment Settings
 NODE_ENV=development
 PORT=3000
 
 # MinIO Configuration file
 MINIO_ENDPOINT=d081-2409-40e3-5e-2bc0-bc90-7a48-347a-3471.ngrok-free.app
 MINIO_PORT=443
 MINIO_ACCESS_KEY=himanshuyadav
 MINIO_SECRET_KEY=#Himan123
 MINIO_BUCKET=mx-healthcare

How can I resolve the ENETUNREACH and ETIMEDOUT errors when trying to connect MinIO using Ngrok in this deployment setup?
Is using Ngrok for this purpose reliable, or are there better alternatives for exposing MinIO on Render Cloud?

Trusted IT Asset Disposal: Maximize Value and Minimize Risk

Brass Valley ITAD Services provide secure, environmentally responsible, and efficient solutions for managing the end-of-life of your IT assets. Whether you’re a small business or a large enterprise, our expert team ensures that your outdated or surplus equipment is disposed of properly while protecting sensitive data. We specialize in data destruction, certified recycling, and asset recovery, ensuring compliance with industry standards and environmental regulations. With Brass Valley ITAD Services, you can rest assured that your IT assets are handled with care, maximizing value and minimizing risk. Trust us to securely manage your IT asset disposition needs, from secure data wiping to responsible recycling, all while maintaining the highest levels of confidentiality and sustainability.

Brass Valley ITAD Services offers secure, eco-friendly solutions for data destruction, asset recovery, and IT asset disposal, ensuring compliance and protecting your business from data breaches and environmental impact.

Canceling Draggable div revert animation on react

I have a div draggable

<div draggable={true}>test</div>

In this div I can drag the div and drop, then it revert to the former position with animation,

However I want to cancel this animation, ( for example change the order of buttons)

How can I cancel the revert animation?

Failed to resolve module aws-amplify. AppSync GraphQL query using Javascript [duplicate]

I have a pretty basic HTML, CSS, JavaScript web app. I have a DynamoDB in AWS and set up an AWS AppSync GraphQL to access the data and pass it to my frontend javascript.

I have an aws-export.js file and my main.js looks like this:

import { Amplify, API, graphqlOperation } from 'aws-amplify';
import awsExports from './aws-exports';

Amplify.configure(awsExports);
import { listMedia } from './queries';

async function fetchMedia() {
  try {
    const response = await API.graphql(graphqlOperation(listMedia));
    console.log('Fetched Media:', response.data.listMedia.items);
  } catch (error) {
    console.error('Error fetching media:', error);
  }
}

fetchMedia();

I’ve downloaded aws-amplify (npm install aws-amplify) and the package exists in my package.json file.

Yes, my javascript file is in my index.html file.

What is happening on load is I get this error:

Uncaught TypeError: Failed to resolve module specifier "aws-amplify". Relative references must start with either "/", "./", or "../".

I have tried to load AWS-Amplify using the CDN but it does not resolve the issue.

An expected solution would be execution of my main.js file to either the try or catch statement of the fetchMedia() function.

Google Form app script to add email to calendar event returns ReferenceError: email is not defined at onFormSubmit(Code:47:34)

I thought this would be simple. I have a Google Calendar Event and a Google Form. I’m trying to edit the app script so that when the user submits their email address, the only field on the form, it will add them to the Google Calendar Event specified by ID.

Calendar Event: https://calendar.google.com/calendar/event?action=TEMPLATE&tmeid=NmRsbDFvbGxmbHZnY2xhcHE3MWE5MWJ1bDEgbGJAZW1haWxpbmR1c3RyaWVzLmNvbQ&tmsrc=lb%40emailindustries.com

Google Form Submitter View: https://docs.google.com/forms/d/e/1FAIpQLSfnU2sK8g4R84XLyjasyJCMkT32R2t3xpgoOZvwddlacT-rNA/viewform

The app script:

/**
 * Sends a calendar invite to the email address provided in the form response.
 *
 * @param {Object} e The form submit event object.
 */
function onFormSubmit(e) {
  // Get the form response.

  var itemResponses = e.response.getItemResponses();

  // Get the email address from the form response.  Assumes the *first* email field.
  //  Better would be to search by question title or ID.
  var email = "";
  for (var i = 0; i < itemResponses.length; i++){
    if (itemResponses[i].getItem().getType() === FormApp.ItemType.TEXT){
      email = itemResponses[i].getResponse();
      Logger.log(email);
      break; // Stop after finding the first email field.
    }
  }

  if (!email) {
    Logger.log("No email address found in the form response.");
    return; // Exit if no email is found.
  }

  // Get the calendar event.
  var calendarId = "[email protected]"; // Your calendar ID
  var calendar = CalendarApp.getCalendarById(calendarId);
  Logger.log(calendar);
 const eventId = "NmRsbDFvbGxmbHZnY2xhcHE3MWE5MWJ1bDEgbGJAZW1haWxpbmR1c3RyaWVzLmNvbQ"
 
 try {
    const event = calendar.getEventById(eventId);

    event.addGuest(email);
    Logger.log("Invite sent to " + email);

    if (event) {
      event.addGuest(email);
      Logger.log(`Invited ${email} to event ${event.getTitle()}`);
      return `Successfully invited ${email} to ${event.getTitle()}.`; // Success message
    } else {
      Logger.log(`Event with ID ${eventId} not found.`);
      return `Error: Event not found.`; // Event not found message
    }
  } catch (error) {
    Logger.log(`Error inviting ${email}: ${error}`);
    return `Error inviting ${email}: ${error.message}`; // Detailed error message
  }
}

I’ve made sure that the Project for the app script has scope on the Google Calendar V3 API

I’ve tried a fresh start because the first time I hadn’t added the Calendar scope before I deployed and I needed to trigger the reauthorization of the project after adding the calendar scope.

I also tried changing the variable name to emailAddress instead of just email but it still throws the exact same error.

What am I doing wrong here?

Getting `ReferenceError: dis is not defined` when using Spidermonkey’s JS shell

According to the Spidermonkey hacking tips documentation, the JS Shell provides a function called dis that dumps the bytecode of a function. However, when I try to use it, I get an error:

Code:

function main() {
  console.log('Hello World');
}

dis(main);

Error:
ReferenceError: dis is not defined

Setup Details:

Disable event listener in javascript in console

I have a page with a bunch of links that have event listeners attached to prevent links opening in new windows. The follow event listener is attached and I can’t work out how to disable it

a => {
  o.target === "_blank" ? (a.preventDefault(), window.open(o.getAttribute("href"))) : window.location.href = o.getAttribute("href")
}

I can’t use CONTROL plus CLICK to open the link in a new tab because the above Javascript loads the URL in the current window. Any ideas how to disable it using the Terminal? I’ve tried:
$('td a').unbind();
and
$('a').off("click");
to no avail. The event stays attached to my links. How can I disable this?

Get namespace of current page MediaWiki userscript

So, I’m creating a Wikipedia user script, and for it, I need to get the current namespace and get a true or false value. I tried using wgCanonicalNamespace , but this did not work. Here is another script I tried but did not work.

NoRedLinksNamespaces = {
    //settings (changed by user on common.js)
};


if(NoRedLinksNamespaces[document.URL.slice("title=", ":")]) {
    //code here
}

I want the script to only redirect certain namespaces, (definition I’m going by: “file:” is file, and “talk:” is talk) out of the editor. here is my code.

How can I create an event form to use it with Fullcalendar

I feel lost. I’ve been trying to get the title from form and update the calendar. Can someone help me to create an event form? I don’t have enough experience with JQuery. First I thought adding eventlistener for button would solve the problem. But it didn’t.

HTML script:

<!DOCTYPE html>
<html>
 <head>
  {% from "formhelpers.html" import render_field %}
  <title> Calendar </title>
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/fullcalendar/3.4.0/fullcalendar.css" />
  <link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css">
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
  <script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>

  <script src="https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min.js"></script>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.18.1/moment.min.js"></script>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/fullcalendar/3.4.0/fullcalendar.min.js"></script>
  <script>
  $(document).ready(function() {
   var calendar = $('#calendar').fullCalendar({
    editable:true,
    header:{
     left:'prev,next today',
     center:'title',
     right:'month,agendaWeek,agendaDay'
    },
    events: [{% for row in calendar %}{ id : '{{row.id}}', title : '{{row.title}}', start : '{{row.start_event}}', end : '{{row.end_event}}', }, {% endfor %}],
    selectable:true,
    selectHelper:true,
    select: function(start, end, allDay)
    {
     document.getElementById("eventblock").style.display="block"
     var title = prompt("Enter Event Title");
     if(title)
     {
      var start = $.fullCalendar.formatDate(start, "Y-MM-DD HH:mm:ss");
      var end = $.fullCalendar.formatDate(end, "Y-MM-DD HH:mm:ss");
      $.ajax({
       url:"/insert",
       type:"POST",
       data:{title:title, start:start, end:end},
       success:function(data)
       {
         //alert(data)
        alert("Added Successfully");
        window.location.replace("/");
       }
      })
     }
    },
    editable:true,
    eventResize:function(event)
    {
     var start = $.fullCalendar.formatDate(event.start, "Y-MM-DD HH:mm:ss");
     var end = $.fullCalendar.formatDate(event.end, "Y-MM-DD HH:mm:ss");
     var title = event.title;
     var id = event.id;
     $.ajax({
      url:"/update",
      type:"POST",
      data:{title:title, start:start, end:end, id:id},
      success:function(){
       calendar.fullCalendar('refetchEvents');
       alert('Event Update');
      }
     })
    },

    eventDrop:function(event)
    {
     var start = $.fullCalendar.formatDate(event.start, "Y-MM-DD HH:mm:ss");
     var end = $.fullCalendar.formatDate(event.end, "Y-MM-DD HH:mm:ss");
     var title = event.title;
     var id = event.id;
     $.ajax({
      url:"/update",
      type:"POST",
      data:{title:title, start:start, end:end, id:id},
      success:function()
      {
       calendar.fullCalendar('refetchEvents');
       alert("Event Updated");
      }
     });
    },

    eventClick:function(event)
    {
     if(confirm("Are you sure you want to remove it?"))
     {
      var id = event.id;
      $.ajax({
       url:"/ajax_delete",
       type:"POST",
       data:{id:id},
       success:function()
       {
        calendar.fullCalendar('refetchEvents');
        alert("Event Removed");
       }
      })
     }
    },

   });
  });

  </script>
 </head>
 <body>
  <br />
  <h2 align="center"><a href="#"> Calendar </a></h2>
  <br />

  <div class="row" style="">
   <div class="column" id='calendar' style="float: left; width: 40%; padding: 5px;"></div>
   <div class="column" id='eventblock' style="background-color: yellow; float: right; width: 40; padding: 5px;">
    <div style="margin-left: 60px;" >
    <form method=post>
      <dl>
       <dt id="titleForm">{{ render_field(form.title) }} </dt>
      </dl>
      <button type="submit">Submit</button>
    </form>
</div>
   </div>

 </div>

 </body>
</html>

Flask script:

from flask import Flask, render_template, request, jsonify
from flask_mysqldb import MySQL
from wtforms import Form, StringField, TextAreaField, PasswordField, validators

app = Flask(__name__)
app.secret_key = "waytoosecret"

app.config["MYSQL_HOST"] = "localhost"
app.config["MYSQL_USER"] = "root"
app.config["MYSQL_PASSWORD"] = ""
app.config["MYSQL_DB"] = "calendar"
app.config["MYSQL_CURSORCLASS"] = "DictCursor"

db = MySQL(app)

class EventBlockForm(Form):
    title = StringField("Title")
    #description = StringField("")

@app.route('/', methods=["POST", "GET"])
def index():
    form = EventBlockForm(request.form)
    cur = db.connection.cursor()
    cur.execute("SELECT * FROM events ORDER BY id")
    calendar = cur.fetchall()
    return render_template('index.html', calendar=calendar, form = form)


@app.route("/insert", methods=["POST", "GET"])
def insert():
    cur = db.connection.cursor()
    form = EventBlockForm(request.form)

    if request.method == 'POST':

        #title = request.form['title']
        title = form.title.data
        #desc = form.description.data


        start = request.form['start']
        end = request.form['end']
        print(title)
        print(start)
        cur.execute("INSERT INTO events (title,start_event,end_event) VALUES (%s,%s,%s)", [title, start, end])
        db.connection.commit()
        cur.close()
        msg = 'success'
    return jsonify(msg)


@app.route("/update", methods=["POST", "GET"])
def update():
    cur = db.connection.cursor()
    if request.method == 'POST':
        title = request.form['title']
        start = request.form['start']
        end = request.form['end']
        id = request.form['id']
        print(start)
        print(end)
        cur.execute("UPDATE events SET title = %s, start_event = %s, end_event = %s WHERE id = %s ",
                    [title, start, end, id])
        db.connection.commit()
        cur.close()
        msg = 'success'
    return jsonify(msg)


@app.route("/ajax_delete", methods=["POST", "GET"])
def ajax_delete():
    cur = db.connection.cursor()
    if request.method == 'POST':
        getid = request.form['id']
        print(getid)
        cur.execute('DELETE FROM events WHERE id = {0}'.format(getid))
        db.connection.commit()
        cur.close()
        msg = 'Record deleted successfully'
    return jsonify(msg)


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

I’ve tried to add listener to get title info from form. Then checked a lot of posts on here.

Access camera on external device while connect to locally server using ip adress

I have a problem that i want to access camera stream on external device which is connect to a same network with local server and accessed by ip server. If i open the camera on external devices the camera cannot stream anyway, it just a blank.

I’m using laravel framework actually, and ill provide my js to open my cam below:

function openCameraModal() {
            cameraModal.classList.remove('hidden');
            if (navigator.mediaDevices && navigator.mediaDevices.getUserMedia) {
                navigator.mediaDevices.getUserMedia({ video: true })
                    .then(stream => {
                        camera.srcObject = stream;
                    })
                    .catch(err => {
                        console.error('Camera access error:', err);
                        alert('Could not access camera. Please enable camera permissions.');
                    });
            } else {
                console.error('getUserMedia not supported on this browser.');
                alert('Your browser does not support camera access. Please use a different browser.');
            }
        }         
  }         
}
<video id="camera" class="w-full h-auto rounded-lg border-2 border-white shadow-xl" autoplay></video>
<canvas id="snapshot" class="hidden"></canvas>

Does anyone have any solution for this problem? Thankyou

I have no idea about how to solve this problem actually.

Error in React Authentication System: Cannot Access Login Response Data

Problem

So I’m building a MERN stack application with authentication, but I’m encountering an error in my login functionality.

Error:

AuthProvider.js:29 Error
    at Object.loginAction (AuthProvider.js:27:1)
overrideMethod  @   hook.js:608
loginAction @   AuthProvider.js:29
await in loginAction        
handleSubmit    @   Login.jsx:16
processDispatchQueue    @   react-dom-client.development.js:16122
(anonymous) @   react-dom-client.development.js:16725
batchedUpdates$1    @   react-dom-client.development.js:3129
dispatchEventForPluginEventSystem   @   react-dom-client.development.js:16281
dispatchEvent   @   react-dom-client.development.js:20352
dispatchDiscreteEvent   @   react-dom-client.development.js:20320

The password is correct since I already hitted the api with postman. For backend refer (which is solved right now): Cannot read properties of undefined (reading ‘_id’) and Cast to ObjectId failed for value for express router
:

A screenshot of the error on my machine

My codebase is as follows:

components/router/routes.js:

import React from "react";
import { Navigate, Outlet } from "react-router-dom";
import { useAuth } from "../../hooks/AuthProvider";

const PrivateRoute = () => {
    const user = useAuth();
    if(!user.token) return <Navigate to="/login" />
    return <Outlet />;
};

export default PrivateRoute;

components/login/Login:

import React from 'react';
import { useState } from 'react';
import { useAuth } from '../../hooks/AuthProvider';

const Login = () => {
    const [input, setInput] = useState({
        email:"",
        password:"",
    });
    
    const auth = useAuth();

    const handleSubmit = (e) => {
        e.preventDefault();
        if(input.email !== "" && input.password !== ""){
            auth.loginAction(input);
            return;
        }
        alert("please provide a valid input!");
    };

    const handleInput = (e) => {
        const { name, value } = e.target;
        setInput((prev) => ({
            ...prev,
            [name] : value,
        }));
    };

  return (
    <div>
        <section className="bg-gray-50 dark:bg-gray-900">
            <div className="flex flex-col items-center justify-center px-6 py-8 mx-auto md:h-screen lg:py-0">
                <a href="#" className="flex items-center mb-6 text-2xl font-semibold text-gray-900 dark:text-white">
                    <img className="w-8 h-8 mr-2" src="https://flowbite.s3.amazonaws.com/blocks/marketing-ui/logo.svg" alt="logo" />
                    Flowbite    
                </a>
                <div className="w-full bg-white rounded-lg shadow dark:border md:mt-0 sm:max-w-md xl:p-0 dark:bg-gray-800 dark:border-gray-700">
                    <div className="p-6 space-y-4 md:space-y-6 sm:p-8">
                        <h1 className="text-xl font-bold leading-tight tracking-tight text-gray-900 md:text-2xl dark:text-white">
                            Sign in to your account
                        </h1>
                        <form className="space-y-4 md:space-y-6" action="#" onSubmit={handleSubmit}>
                            <div>
                                <label htmlFor="email" className="block mb-2 text-sm font-medium text-gray-900 dark:text-white">Your email</label>
                                <input type="email" name="email" id="email" className="bg-gray-50 border border-gray-300 text-gray-900 rounded-lg focus:ring-primary-600 focus:border-primary-600 block w-full p-2.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-blue-500 dark:focus:border-blue-500" placeholder="[email protected]" required="" onChange={handleInput}/>
                            </div>
                            <div>
                                <label htmlFor="password" className="block mb-2 text-sm font-medium text-gray-900 dark:text-white">Password</label>
                                <input type="password" name="password" id="password" placeholder="••••••••" className="bg-gray-50 border border-gray-300 text-gray-900 rounded-lg focus:ring-primary-600 focus:border-primary-600 block w-full p-2.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-blue-500 dark:focus:border-blue-500" required="" onChange={handleInput}/>
                            </div>
                            <div className="flex items-center justify-between">
                                <div className="flex items-start">
                                    <div className="flex items-center h-5">
                                        <input id="remember" aria-describedby="remember" type="checkbox" className="w-4 h-4 border border-gray-300 rounded bg-gray-50 focus:ring-3 focus:ring-primary-300 dark:bg-gray-700 dark:border-gray-600 dark:focus:ring-primary-600 dark:ring-offset-gray-800" required="" />
                                    </div>
                                    <div className="ml-3 text-sm">
                                        <label htmlFor="remember" className="text-gray-500 dark:text-gray-300">Remember me</label>
                                    </div>
                                </div>
                                <a href="#" className="text-sm font-medium text-primary-600 hover:underline dark:text-primary-500">Forgot password?</a>
                            </div>
                            <button type="submit" className="w-full text-white bg-primary-600 hover:bg-primary-700 focus:ring-4 focus:outline-none focus:ring-primary-300 font-medium rounded-lg text-sm px-5 py-2.5 text-center dark:bg-primary-600 dark:hover:bg-primary-700 dark:focus:ring-primary-800">Sign in</button>
                            <p className="text-sm font-light text-gray-500 dark:text-gray-400">
                                Don’t have an account yet? <a href="#" className="font-medium text-primary-600 hover:underline dark:text-primary-500">Sign up</a>
                            </p>
                        </form>
                    </div>
                </div>
            </div>
        </section>
    </div>
  );
};

export default Login;   

components/dashboard/Dashboard:

import React from "react";
import { useAuth } from "../../hooks/AuthProvider";

const Dashboard = () => {
    const auth = useAuth();
    return(
        <div className="container">
            <div>
                <h1>Welcome!  {auth.user?.username} </h1>
                <button onClick={() => auth.logOut()} className="btn-submit">
                    logout
                </button>
            </div>
        </div>
    );
};

export default Dashboard;

App.js:

import NavBar from './components/navbar/NavBar';
import './App.css';
import AuthProvider from './hooks/AuthProvider';
import Login from './components/login/Login';
import PrivateRoute from './components/router/route';
import Dashboard from './components/dashboard/Dashboard';
import { BrowserRouter as Router, Routes, Route } from 'react-router-dom';

function App() {
  return (
    <div className="App">
      <Router>
        <AuthProvider>
          <Routes>
            <Route path='/' element={<Login />}/>
            <Route element={<PrivateRoute />}>  
              <Route path='/dashboard' element={<Dashboard />}/>
            </Route>
            {/* Other routes */}
          </Routes>
        </AuthProvider>
      </Router>
    </div>
  );
}

export default App;

Additionally here is the git repo link to help: https://github.com/prathamesh-patil-5090/INOTES

Please help me out here!

Bootstrap v4.1.0 Nav Bar Dropdown Alignment Issue [duplicate]

I’ve created a nav bar using Bootstrap v4.1.0 and have encountered an issue with the last drop down that appears on the right which has a couple of options in the drop down menu.

Here’s a screenshot of how it looks:

enter image description here

You can see it is truncating the drop down menu contents (first option should show Change Password).

Here’s the code for the nav bar:

<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.7.1/jquery.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.min.js"></script>
<link
  href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css"
  rel="stylesheet"
/>
<nav class="navbar navbar-expand-md navbar-dark bg-dark fixed-top">
  <a class="navbar-brand" href="#"
    ><img src="images/logo.jpg" width="165" height="36" alt=""
  /></a>
  <button
    class="navbar-toggler"
    type="button"
    data-toggle="collapse"
    data-target="#navbarsExampleDefault"
    aria-controls="navbarsExampleDefault"
    aria-expanded="false"
    aria-label="Toggle navigation"
  >
    <span class="navbar-toggler-icon"></span>
  </button>

  <div class="collapse navbar-collapse" id="navbarsExampleDefault">
    <ul class="navbar-nav mr-auto">
      <li class="nav-item dropdown">
        <a
          class="nav-link dropdown-toggle"
          id="dropdown01"
          data-toggle="dropdown"
          aria-haspopup="true"
          aria-expanded="false"
          >Organisations</a
        >
        <div class="dropdown-menu" aria-labelledby="dropdown01">
          <a class="dropdown-item" href="organisations.php?action=showall"
            >Companies</a
          >
          <a class="dropdown-item" href="organisationsSearch.php"
            >Search Organisations</a
          >
        </div>
      </li>
      <li class="nav-item active dropdown">
        <a
          class="nav-link dropdown-toggle"
          id="dropdown01"
          data-toggle="dropdown"
          aria-haspopup="true"
          aria-expanded="false"
          >Contacts</a
        >
        <div class="dropdown-menu" aria-labelledby="dropdown01">
          <a class="dropdown-item" href="contacts.php?action=showall">People</a>
          <a class="dropdown-item" href="contactsSearch.php">Search Contacts</a>
        </div>
      </li>
      <li class="nav-item dropdown">
        <a
          class="nav-link dropdown-toggle"
          id="dropdown01"
          data-toggle="dropdown"
          aria-haspopup="true"
          aria-expanded="false"
          >Projects</a
        >
        <div class="dropdown-menu" aria-labelledby="dropdown01">
          <a class="dropdown-item" href="projects.php?action=showall"
            >Projects
          </a>
          <a class="dropdown-item" href="projectsSearch.php">Search Projects</a>
        </div>
      </li>
    </ul>
    <ul class="nav navbar-nav navbar-right">
      <li class="nav-item dropdown">
        <a
          class="nav-link dropdown-toggle"
          id="dropdown01"
          data-toggle="dropdown"
          aria-haspopup="true"
          aria-expanded="false"
          >Fred Flinstone</a
        >
        <div class="dropdown-menu" aria-labelledby="dropdown01">
          <a
            class="dropdown-item"
            href="changePassword.php?action=changePassword"
            >Change Password</a
          >
          <a class="dropdown-item" href="logout.php">Logout</a>
        </div>
      </li>
    </ul>
  </div>
</nav>

I haven’t been able to work out how to get these not to truncate along the right.