Questions tagged [express]

Express.js is an innovative and versatile framework for developing web applications on Node.js, offering a comprehensive range of powerful features that enable seamless creation of robust web solutions.

Express.js Res redirection problem occurring with Backbone.js due to failure in redirecting hashtag URLs

Issue Summary: Having trouble with Express.js redirect functionality. The problem occurs when trying to redirect after entering /#impulse, but works fine with /impulse/. Server processes the request for /#impulse before applying redirect checks, which re ...

Initiating a post request to the express server

My service includes a function that retrieves the user's current location using latitude and longitude coordinates. I am attempting to send this information to my server in order to incorporate it into a query. However, my post request does not appear ...

Firebase Integrations: How to Handle Errors in External API Calls within Firebase Functions

My current challenge involves retrieving data from an external API using Firebase functions and displaying it in an Angular application hosted on Firebase. Billing is enabled for the project. The API call works fine on localhost, but fails to fetch data wh ...

Analyzing User Input and Database Information with Mongodb

Here's the HTML form I'm working with: <form id="contact-form" method="POST" action="/search"> <label for="company">Phone company</label> <input type="text" name="company" value=""> <br> ...

Retrieving variables using closures in Node.js

I have been developing thesis software that involves retrieving variables within closures. Below is the code snippet written in node.js: var kepala = express.basicAuth(authentikasi); // authentication for login function authentikasi(user, pass, callback ...

There was an issue executing GraphicsMagick/ImageMagick: the operation "identify" with the arguments "-ping" and "-format" "%wx%h" could not be completed

I am currently attempting to locate the measurements of the images on a production machine, but encountering errors. An error occurred while trying to execute GraphicsMagick/ImageMagick: identify "-ping" "-format" "%wx%h" "uploads/userPhoto-149966968519 ...

SSR routing with parameters in Angular Universal seems to be failing after intial navigation

I'm currently experiencing an issue with routing using path parameters: Navigation works perfectly when moving between categories initially, but once I navigate from one category to another, the routing doesn't update even though the URL in the ...

Deployment of the API and frontend on separate subdomains and domains respectively within the Google Cloud Platform

My journey began by setting up a Google App Engine where I deployed both the API and the frontend on my custom domain, which I referred to as mysite.ms. The API was written in nodejs with Express, while the frontend was a React application. To achieve this ...

utilize a function to format text in dust.js style

I have created a JavaScript function that blurs text: function blurText(data) { var dataSplit = data.split(" "); var lastWord = dataSplit.pop(); var toBlur = '<span class="blur">' + dataSplit.join(" ") + '</span>&ap ...

Utilizing the MEAN stack to establish a connection with a simulated data collection

Currently, I am diving into the world of M.E.A.N stack development. As part of my learning process, I have successfully set up a test page where Angular.js beautifully displays and re-orders data based on search criteria. To challenge myself further, I dec ...

The integration between Multer file uploads and SwaggerExpress is not functioning properly

I'm encountering an issue while attempting to upload multipart form data using multer. I have integrated swagger express middleware for my APIs. Strangely, everything was functioning correctly before implementing swagger. However, after integrating sw ...

An issue encountered with res.download() following res.render() in Node.js

Just started working with Node JS and ran into an issue: Error: Can't set headers after they are sent. I've checked my code, and the problem seems to be related to res.download(); Is there a way to display the view without using res.render()? ...

Unable to retrieve MongoDB attributes or methods

I'm attempting to access properties or functions within mongoose.connection in order to retrieve the DeleteMany and DropCollection methods, but I seem to be unable to do so. I am initiating the express.js server inside the mongoose connection. mongoos ...

What is the process for making a specific query in MongoDB?

I currently have 3 blog posts stored in my MongoDB database and I am looking to retrieve a specific blog post based on its name. Here is an example of how the data is structured: [ { _id: ObjectId("61de0e1562abb7ffd4089373"), name: 'le ...

Retrieving information from MongoDB

Currently, I am working on retrieving data from MongoDB and passing it to my Express server to eventually display it in my HTML using Angular. The retrieval process is successful when there is only one record in the database. However, if multiple records a ...

Error message "Uncaught ReferenceError: io is not defined" is displayed by Socket.io

I've been working on integrating sockets into my app, but have run into an error https://i.stack.imgur.com/4lUF7.png Interestingly, when I tested the socket functionality in a separate test app using the same code, everything worked perfectly. However, wi ...

`req.user` seems to be unresolved, but it is actually defined

Currently, I am working on developing an Express.js application that utilizes Passport.js for authentication in an administration panel. The program is functioning correctly at the moment, with my app.js initializing passport and setting up sessions proper ...

The issue of receiving a 500 error when making a POST request in node.js

I have created my own unique REST API that utilizes an NLP API internally. I need to post data on their URL, but unfortunately I am encountering an error that is causing my API to return a 500 error to the frontend. Below is a snippet of my server.js code ...

Getting a JWT token from Express to Angular using ngResource: A step-by-step guide

Currently, I am utilizing a jwt token for user registration validation. A unique URL is generated and sent to the user via email, which leads them to the authentication page. On the server side, the token is decoded and I need to transmit this JSON data to ...

Shutting down several ports with an Express application

Currently, my app is running on multiple server instances on different ports. I achieve this by using the command "npm run node_1 & npm run node_2", which runs the app on localhost at ports 3001 and 3002. The issue arises when I attempt to close the applic ...

What is the best way to retrieve the content from the MongoDB Document in my GET request?

I encountered an issue while attempting to access the Question field within the JSON document body stored in a MongoDB database. Upon executing the GET request, the result displayed as follows: { "_readableState": { "objectMode": true, "highWaterM ...

Error code E11000 is thrown due to a duplicate key in a Node.js application

Whenever I input data on the webpage, it syncs correctly with the database. However, when I attempt to fill out the same form again, an error occurs: { "code": 11000, "index": 0, "errmsg": "E11000 duplicate key error collection: test.creates i ...

Passport causing Node.JS application to crash

After developing my app to work locally, I made all necessary adjustments for Heroku. Procfile web: node app.js package.json { "name": "HipsterMatch", "version": "0.0.1", "private": true, "scripts": { "start": "nodemon app.js" }, "depen ...

Express now has the capability to utilize a .pfx file that contains an encrypted private key without requiring the password for the private key

I have a situation where my express instance is using an unencrypted pfx file that contains my certificate and an encrypted private key. Surprisingly, when I load the pfx in express, it works without needing to provide any password. This has left me wonder ...

Could it be that the function is returning undefined because console.log is executing before the result is actually returned? Perhaps a promise

There is a function located in another file that I need to extract the response from and perform an action based on that response before completing my controller function. This is the snippet of code from the external file: exports.counter = function(com ...

Having trouble invoking an established route within a different route in an Express JS project

While working with an Express JS application connected to a mySQL database, I encountered an issue when trying to fetch data from a pre-defined route/query: // customers.model.js CUSTOMERS.getAll = (result) => { let query = "SELECT * FROM custo ...

Managing the callback function for multer file filtering

I have created a simple function to upload and write image files to the server using Express + Multer. Now, I am trying to handle callback errors in order to return an error message to the client like: {success:false,message:'Only images are allowed& ...

The recognition of express is an issue in the Bitnami MEANstack environment

Recently, I set up a native installation of Bitnami MEAN stack on my Windows system and followed their tutorial to create a new project. However, when attempting step 3 by running the command express myproject, I encountered an error message stating that ' ...

redirecting from an AJAX request

Seeking a way to perform a redirect following an ajax `put` request. My intention is to implement client-side validation using pure JS. Client: $(document).ready(function() { login = () => { var username = $("[name='username']").val() ...

Tips on saving an audio file to a Node server using blob or FormData

I am currently working on a project where I have a MedaRecroder stream recorded in audio/webm format. The stream is sent to a Node server, and while the file appears in the response under req.files, there seem to be encoding errors when playing it back. M ...

Sails.js's powerful full text search capability

Can Sails.js and/or Waterline support full text search? While PostgreSQL does support full text search, it appears that the PostgreSQL adaptor for Waterline may not have this feature. Is an efficient full text search achievable with Waterline's cont ...

What is preventing me from running the npm run dev command? (node.js/express.js/typescript)

I'm having trouble running npm run dev for my project (Node.js / Express.js / Typescript). I've followed the instructions in the links below but I still keep getting errors. PS C:\Users\Yasser\Documents\WorkspaceNodeJS\M ...

Store the user's login credentials securely in the browser's local storage

Currently, I am implementing user authentication in Node Express with EJS using JWT. The generated token is stored in cookies using the following code: res.cookie('authorization', token, {maxAge: 3 * 60 * 60 * 1000}); During verification, I can ...

The login request through Express and Passport does not complete or finalize

I have implemented authentication in my express app using passport, passport-local and passport-jwt. The login code below generates a token which is then sent back via the response object. However, when attempting to login using Postman, the request never ...

Utilize Express and Passport to enable simultaneous login for various 'local' accounts

Apologies in advance for any language or technical errors, as English and Node are not my strong suits. I have resorted to using Google Translation for assistance since solutions within my local sphere are unavailable. EQUIPMENT USED Ubuntu 16.04 locally ...

Encountering difficulties retrieving form data in NodeJS Express

I'm currently facing an issue with my form where I am trying to fetch data from the server using ejs templating in my node app. Everything seems fine as there are no errors displayed, but unfortunately, I am unable to retrieve the data in the console. Her ...

I am unable to access a file on the server even after exposing it using express

In my current project, I am facing a challenge with storing and allowing end users to download text files dynamically from the browser. While the ideal solution would involve using an object store like MINIO or S3, I am limited to using in-memory storage a ...

Total number of requests made since the previous reset

I'm currently working on developing an API and I need to set up a route like api/v1/status in order to check the server status. This route should return a JSON response with the total number of requests made to the API since it became active. However, I am ...

I wonder what the outcome would be if I used res.send to send a JSON file instead of res.json

Is it possible to send a JSON file using res.send in NodeJs instead of res.json? What are the potential consequences of doing this and why is it recommended to avoid this practice? ...

Updating a Mongo Record using the ID obtained from another Record's retrievalI hope this meets your needs

One of my current tasks involves creating an API endpoint with specific functionality. The goal is to input an Object ID into the path, locate the record associated with that ID, access a particular field within this object which contains another ObjectID ...

Utilizing Express.js routes with optional parameters: regardless of the path chosen, it will always lead to the

My express js app has two different routes defined as follows: 1. router.route('/art/:category/:fieldName/:tag/:count(\\d+)?/:perPage(\\d+)?') 2. router.route('/art/search/:keyword/:count(\\d+)?/:perPage(&bsol ...

Ways to retrieve all local variables in an Express view

I'm exploring options to access all the app.locals within views. Here's what I have in my app.js: app.locals.title = "Title" app.locals.page = "Page 1" These work fine, and I can easily use them in views like this: <%= title %&g ...

Understanding NodeJS Code

As a newcomer to nodejs, I've been delving into some code and trying to grasp its concepts. Could someone kindly guide me in understanding the following code snippets? My inquiries might be basic, but please note that I'm on a learning curve with nodejs an ...

Encountering Issues with File Uploads in Express.js with Multer

Currently, I am immersing myself in Node.js through the guidance of a book titled "Web Development with Nodejs and MongoDB." However, I have hit a roadblock when attempting to upload an image using Multer. The code snippet causing me trouble is as follows: ...

Executing Java program from a Node.js application

After researching, I discovered a few methods for running `java` files within a `node.js` application. One option is to spawn a child process: (where the java code is contained with dependencies in an executable `jar`). var exec = require('child_proc ...

Express error handler failed to catch the validation error

I have a field type in my mongoose schema that is required. I've implemented a custom error handler in express like this: const notFound = (req, res, next) => { const error = new Error(`Not found-${req.originalUrl}`); res.status(404); next(er ...

Is it possible for me to determine whether a javascript file has been executed?

I am currently working with an express framework on Node.js and I have a requirement to dynamically change the value (increase or decrease) of a variable in my testing module every time the module is executed. Is there a way to determine if the file has ...

Passing Variables from Node JS to Pug Template's HTML and JavaScript Sections

Here is a route that sends various variables to a Pug template: items.js route router.get('/edit/:itemObjectId', async function(req, res, next) { var itemObjectId = req.params.itemObjectId; var equipmentCategoryArr = []; var lifeExp ...

"Error message received while attempting an HTTP GET request in Node.js

When attempting to make an HTTP GET request, I encountered the following error. Can anyone provide guidance on how to resolve this issue? var https = require('http'); var options = { host: 'lifecycle-dev.elasticbeansta ...

Incorporating code execution during promise completion

I'm currently working on an express application that involves a generator function which takes approximately 5 minutes to process a large amount of data. Unfortunately, I am unable to optimize this function any further. Express has a built-in ti ...

Issue with AWS API Gateway and Restful API: socket.io encounters an error stating that the route '/socket.io?EIO=4&t=xxx&transport=polling' does not exist

My backend API services are hosted on AWS using API Gateway and EC2 instance. The backend is built with Node.js/Express JS, and socket.io is used for real-time messaging. const initializeExpress = (): void => { const app = express(); let http = re ...

Dealing with CORS: Troubleshooting the 'Access-Control-Allow-Origin' issue when a NextJS app deployed on an Nginx server attempts a GET request to a local Express server

While everything worked fine on my local machine, I encountered an issue after deploying to my droplet with nginx/1.18.0 and certbot for HTTPS. The error occurred when attempting a GET request from my NextJS app (localhost:3000) to an express route specifi ...

Unable to access due to CORS restriction on Express server

Whenever I attempt to send a POST api request to my express server, I encounter the following error message. Access to XMLHttpRequest at 'localhost:8081/application' from origin 'localhost:8083' has been blocked by CORS policy: No &apos ...

Guide to Setting up the TRACE Request Response in express.js

The HTTP TRACE method is a valuable tool for conducting a message loop-back test along the path to the target resource, making it an essential debugging mechanism. The final recipient of the request must echo back the received message as the body of a 200 ...

Unable to make changes to the document

Having trouble updating a document by ID using mongoose and typescript. I'm testing the api and passing the id as a parameter. I've experimented with different methods of updating by ID, but for some reason, it's not working. Can update by ...

Troubleshooting the Non-functioning req.value & ip with Node.js - Joi schema

I have implemented a joi schema to validate email and password that are sent as JSON in the request body. Now, I want to add an additional validation for the IP address. However, when I tried to do so, I encountered the following error: { "isJoi": tru ...

System reboots upon socket message reception

I am currently working on developing a chat application using Next, Express, and Socket.io. I have encountered an issue where the state managing the messages in the chat resets every time a new message is sent from one browser to another. You can see an ex ...

The statusMessage variable is not defined within the "res" object in a Node Express application

I am currently developing a Node.js & Express.js application and I am in need of creating a route to display the app's status. router.get('/status', function(req, res) { res.send("Current status: " + res.statusCode + " : " + res.stat ...

How to determine the best location to store images submitted through a POST request and the process for retrieving and transmitting the

Despite the commonality of my issue, I have not been able to find a specific solution due to the various use cases involved. Here is the concept: Users will be uploading images from the front-end, and each upload should generate a JSON entry in the datab ...

What is the best way to get rid of a connect-flash notification?

I'm having trouble removing the message (with the username displayed) after logging out by pressing the logout button. Every time I try to press the logout button, it just refreshes the page without any action. I want to stay on the same page and not be re ...

Error message: The 'Access-Control-Allow-Origin' policy is preventing access in a react express docker application

I have successfully set up a front-end React application and a Node/Express API using Docker. The React app is currently running on localhost:3000, while the API is running on localhost:9000. Both applications are fully functional. However, I am encounteri ...

Establishing the Session Once Headers are Established

Currently, I am working on implementing an asynchronous method that involves making a POST call to a specific API to fetch data and then storing the result in the user's session. Although the task itself seems straightforward, it becomes challenging when a ...

Node.js unable to serve static files due to path issue (unable to access directory "/../")

Seeking Help with Serving CSS Files in Express In my routes.js file, I am trying to figure out how to serve all the files located inside the css folder as static files. Can anyone assist me with this? Screenshot of path structure (Please edit and display ...

Validation of Inputs in the Node ExpressJS Framework

I am using node 0.10.8 and expressJS 3.2.5. Recently, I installed the express-validator package: npm install express-validator In my app.js file: var express = require('express') , i18n = require('i18next') , routes = require('./routes') , user = ...

Obtaining images from the backend within a component's TypeScript file in a MEAN stack application is a

In my component.ts file, I am looking to retrieve images from the backend/images folder as Image objects. The paths of these images are stored in the database. this.productsService.getProduct(this.editId).subscribe(productData => { this.name = prod ...

Encountering an SSH issue while attempting to deploy to Digital Ocean using Gitlab's CI/CD functionality

Hey there, I've been attempting to deploy to Digital Ocean using a Gitlab CI/CD pipeline. However, every time I run the pipeline, I encounter the following error message: "chmod: /root/.ssh/id_rsa: No such file or directory $ chmod og= ~/.ssh/id_rsa C ...

Is it necessary to use next() in express routes?

Many instances in Nodejs/Express showcase that calling next() is not always necessary for success. exports.postLogin = (req, res, next) => { passport.authenticate("local", (err, user, info) => { if (err) { return next(err); } re ...

Playing out the REST endpoint in ExpressJS simulation

Suppose I have set up the following endpoints in my ExpressJS configuration file server.js: // Generic app.post('/mycontext/:_version/:_controller/:_file', (req, res) => { const {_version,_controller,_file} = req.params; const mockDataFi ...

The connection between AngularJS and the Node.js server is struggling with sending input data, resulting in a 404 error message

Why is the HTTP address not found? I am seeing these mistakes in the console: POST http://localhost:3000/api/message 404 (Not Found) angular.min.js XHR finished loading: POST "http://localhost:3000/api/message". angular.min.js Error " ...

Is it possible to combine Mongoose Materialized Path with Mongoose Restify?

After successfully implementing a schema/model for a recursive tree structure in Mongoose, I have decided to enhance my current setup by integrating two specific packages designed to streamline the process: Utilizing mongoose-mpath will allow me to man ...

How can I utilize customToJSON in Sails 1.0 within an Action2 function?

Currently, I am facing an issue with my user model that requires the implementation of a customToJSON method to remove the password field from the returned JSON object. Everything works fine when I include "responseType" in the "exits" with a value of "jso ...

Error: Unable to access 'name' property in reactjs due to undefined value

Here is the frontend code snippet: { (opp||[]).map(opps=>{ return( <div className="card OppCard"> <div className="card-body" > <h4>{opps.title}</h4> <p><b&g ...

Searching for parameters wrongly triggering the id on a different route

Having recently delved into mongoose, I must apologize in advance for any misuse of terminology on my part. Below is the content of my routes file: const express = require('express'); const router = express.Router(); const passport = require('passport'); ...

`Unexpected behavior when using res.redirect()

Both of these code snippets lead to a redirection to the products/:id path. However, there is a difference in how I need to set up the routes. In the post route, I must include products/, but in the put route, I do not need to include it. Does anyone hav ...

Transferring Session ID between Express.js and Socket.io while dealing with iframes from distinct origins

My Node application built with Express.js and Socket.io is facing an issue where they are not sharing the same session ID when running under iframe with different origins. When accessed directly or through iframes with the same origin, everything works fin ...