Despite adding the 'Access-Control-Allow-Origin': '*' header to my Axios request, I am still encountering the same error. When trying to access 'http://backendUrlEndPoint' from origin 'https://frontendURL', the CORS policy blocks the request: The preflig ...
Consider this server route example using expressjs: app.get('/cards', function(req, res) { anUndefinedVariable // Server doesn't crash dbClient.query('select * from cards', function(err, result) { anUndefinedVariab ...
I have been diving into MongoDB through their online Webinar hosted on their platform and I am currently working on connecting Products to a Category (for example, associating iPhones with the Mobiles Category which falls under Electronics). However, as I ...
I'm currently testing a loop function for one of my routes and encountering an issue where it blocks all web calls until the function is completed. I am looking for a way to prevent node from getting locked up while processing this function. app.get('/p ...
I'm currently facing an issue with setting custom headers using express.js's res.render function. I have tried four different methods, but unfortunately, all of them have failed. Below is the code snippet: Method 1 app.get('/login', function(req, res, n ...
I have encountered an issue with a PUT request I am making. Despite receiving a 404 response from my express server, axios always sees it as 200. The correct response is shown in the express logs: PUT /v1/org/password/reset 404 339.841 ms - 71 This is th ...
When my app starts, I aim to download images from MongoDB for faster performance and local access within the application. However, I encounter crashes on Heroku. How can I address this issue? Here is the code snippet I am attempting to implement: dir = " ...
I'm looking to use the fetch API to send requests and have those requests handled by Express JS. In my setup, I've put together server.js (Express JS), index.html (home page), and signin.html (sign-in page). index.html <!DOCTYPE html> <html> ...
I am encountering an issue with my Angular2 app that is using Express. The problem arises when I have a URL like /v2/tickets?filterId=321 and upon page reload, it changes to /v2/tickets/?filterId=321, disrupting the Angular2 routing process. Upon checkin ...
I am facing a query that looks like the following: {"$match": {$or: [{"to": system.mongoose.Types.ObjectId(userId)}, {"from": system.mongoose.Types.ObjectId(userId)}]}}, {"$sort": {"createDate": -1}}, { "$group": { ...
function sendEmail(num, email, customerName) { var readHTMLFile = function (path, callback) { fs.readFile(path, { encoding: 'utf-8' }, function (err, html) { if (err) { throw err; callback(e ...
After hours of contemplation, I'm still struggling to figure out the issue at hand. Let's start with how I defined a route: var home = require('./routes/home'); var app = express(); app.use('/home/:client', home); The code ...
Encountering some issues when trying to save an object created in Express nodejs using mongoose. Despite receiving a confirmation that the object is saved, it cannot be located even after attempting to access it through the server. Express route for savi ...
Currently working on migrating an app from node.js with express framework to meteor. Attempting to reverse engineer the process using a method similar to https://github.com/onmodulus/demeteorizer ...
Recently, I put together a webpage for local use and it involves many routes. Specifically, I have 31 .ejs files and 3 .html files all neatly stored in the "views" folder. //app.js - using node and express app.get('/page1', function(req, res){ ...
I am new to implementing the mean stack. I attempted to view data from the controller, but encountered an error message in the web browser's console. Error: [$controller:ctrlreg] http://errors.angularjs.org/1.6.3/$controller/ctrlreg?p0=AppCtrl Stack trace ...
Example of 'Advanced REST Client' Request I am currently using Postman and Advanced REST client to create a simple POST request based on the code below: 'use strict'; var express = require('express'); var bodyParser = requir ...
I am facing an issue while trying to open the places.ejs file by clicking the submit button on the show.js page. Similar to how the show.ejs page opens upon clicking the submit button on the new.ejs file, I am encountering a reference error. Any assistance ...
I'm currently working on integrating data patching with my Firestore database using http. My goal is to achieve this without relying on an external server, by utilizing Firebase Hosting and Functions. Firstly, I set up my Firebase project and imported exp ...
Is it possible to update a specific section of a webpage using AJAX without having to refresh the entire page? If so, how can this be achieved correctly? //Get Book router.get('/form/:id', (req, res) => { Book.findOne({ _id: req.params.id }) ...
My application seems to have an issue when I start it using 'npm start'. The build process begins but then stops without displaying any error messages. I've let it run for several hours, but it still hasn't completed the building process. Trouble with bu ...
In my express.js application, I'm currently using supertest and should.js as my preferred testing framework. However, I've encountered some difficulties when it comes to testing for specific values within an unordered array. After referring to the documen ...
INDEX.JS import express from "express"; import { APP_PORT } from "./config"; import db from "./database"; import cors from "cors"; import bodyParser from "body-parser"; import Routes from "./routes&quo ...
Whenever I attempt the post method to fetch data on Postman and store it in a local MongoDB database, I encounter an error. The error message indicates a bad request with a status code of 400. *The following is app.js: var express = require('express'); va ...
I am facing an issue with my app.js and route file configuration. Here is my app.js file: const express = require('express'); const app = express(); const port = process.env.PORT || 8080; const userRoute = require('./routes/user.route' ...
Despite Heroku's suggestion to use NPM packages, I've had no luck finding one that successfully forces SSL for express apps. The only solution that seems to work is the following, but it angers Google. Question: Can anyone provide a reliable method in 202 ...
I am currently developing an application in Node.js that requires numerous configuration and database calls to process user data. The problem I am facing is that after reaching 11,800+ function calls, Node throws a RangeError and exits the process. The er ...
I need to create a way for users to upload files to my express backend, but the form is within a react component. How can I incorporate my react ConverterSec2 component into the get function? server.js: import ConverterSec2 from "./ihertz_website/src ...
Allow me to pose a straightforward question: Within NodeJS, there exists the option to define globals using GLOBAL.myConfigObject = {...} I am curious about the opinions of the developer community on whether this method is considered best practice. If n ...
Upon calling the app.post('/form-submit', funtion(req, res)) method, my expectation is for it to first save the data using save(). This works fine, but then when I call the find() method, it shows all the data from the mongoDB database except for the curre ...
Starting with what I have: core.app.get('/download/:key', function (req, res) { require("./../../module/fileupload.js").download(req.params.key, function(file, filename) { console.log(file + " - " + filename); if (file != null) res.dow ...
Is there a way to successfully implement the following structure? [{ "title": "pranam", "year": "2016", "rating": 9, "actors": [ { "name": "Amir", "birthday": "16 Aug 1982", "country": "Banglades ...
I am currently working on a feature that will allow users to save and download static files, but I want these files to only be accessible to logged in (authorized) users. routes/files.js var express = require('express'); var router = express.Router(); /* ...
Within my nx-workspace, I have encountered a scenario where there are 2 separate environment.ts files named environment.ts and environment.prod.ts. I am currently facing an issue with retrieving the base url from the environment.ts file, which corresponds ...
Is it feasible to retrieve all updated values or values with a difference after calling updateOne()? _.each(gameResult, function(gameResult){ bulk.find({"user" : gameResult.user, "section" : gameResult.section , "code" : gameResult.code}).upsert().up ...
I am currently utilizing Passport for authentication in an Express application. This authenticates the user and sets it on the Express response. As I am using TypeScript, trying to set the request type to Request in the route definitions results in an erro ...
Currently, I am in the process of developing a demonstration banking application that facilitates user sign up and sign in functionality using express.js and node.js. The API created accepts POST requests to /signup and /authenticate routes successfully wh ...
Here is a glimpse at my project setup: -backend -server.js -www -index.html -app.css -bundle.js I'm facing an issue with Express not serving static files for URLs that contain 2 or more slashes like this localhost:3000/product/1 However, it w ...
Currently, I am in the process of learning how to build an API with TypeScript and experimenting with testing it using the Jest framework. When utilizing a basic Express application like app = express() supertest(app) everything works smoothly. However, ...
I have embarked on a journey to explore Contentful's headless CMS, but I am encountering a challenge with their API client. My goal is to combine Express with React for server-side rendering, and I am utilizing this repository as my starting point. S ...
I am developing a web application where the layout remains consistent, except for one specific <div>. Currently, I am using routes to handle links, but it feels inefficient to reload the entire layout.ejs file when only the <div> needs to be up ...
I've defined my model like this: const User = db.Model.extend({ tableName: 'users', hasSecurePassword: true }); module.exports = User; With this setup, I can perform actions such as const User = require("../models/user"); ...
My directory structure is as follows: -- app/ |- models/ |- user.js |- config.json I am trying to make my user.js file require the config.json. Currently, I am using require('/config') but it doesn't seem to be working. Can som ...
When attempting to retrieve specific data from my database using AJAX, I encountered an issue where the call was successful when made through Postman or directly in the browser, but failed when initiated from my client. It seemed to work intermittently, re ...
In an effort to retrieve a user's pet based on the user's id and the pet's id. Description of my tables: CREATE TABLE pet_owner ( id serial PRIMARY KEY, first_name varchar(100) NOT NULL, last_name varchar(100) NOT NULL, phone_number ...
Currently, I am utilizing express-session and passport-local for user authentication in my project. My goal is to be able to track currently online users. The login process functions properly, creating a session and storing the user's Id. I can retrieve al ...
In my application's app.js file, I establish a connection to mongodb using the monk module. var express = require('express'); var cookieParser = require('cookie-parser'); var bodyParser = require('body-parser'); var mong ...
I've encountered a unique issue while using the activedirectory module for user authentication with AD. While most users authenticate without any problems, users within a specific OU are constantly facing authentication failures. Below is the code snippet ...
I encountered a syntax error while running a migration script on a sqlite database. Here is the error message I received when executing the migration queries: node:internal/process/promises:288 triggerUncaughtException(err, true /* fromPromise ...
I have a web application built with Node.js using Express.js, and storing data in a MongoDB database with the help of Mongoose. My challenge is to handle a duplicate key error (error code 11000) from MongoDB while still returning a 204 HTTP response. I pla ...
I am currently exploring Node.js as a potential replacement for my existing DOT NET API. I have created middleware to enforce basic non-role authorization in my application, but I am encountering compilation problems with the function inputs. Compilation ...
I am currently developing a web application that utilizes Ajax to submit a file along with some form fields. One unique aspect of my form is that it allows for dynamic input, meaning users can add multiple rows with the same value. Additionally, the form i ...
I'm working on creating a middleware in nodejs for access levels, and I've written the following middleware: class AccessUser extends middlware { async AccessUser(access,req, res, next) { const getTokenFrom = (req) => { const autho ...
Currently, I am trying to extract data from a form and add it as a map to my list. However, an error message is displayed: Cannot read property 'url' of undefined express = require("express"); app = express(); var bodyParser = require("body- ...
Is there a way to display an alert at the top of the browser if the SQL query returns empty results? I tried using the "alert" function, but I'm struggling with customizing its appearance. I have a function in my HTML code that triggers an alert, but ...
I have come across various versions of this particular question, however, none of them seem to address my issue directly. My current objective is to establish a Node.js server using Express. Below is my existing server configuration: var express = require ...
My TCP port 3000 is enabled, as indicated in the EC2 security settings. However, I am unable to connect to my server through telnet on that port and receive the error message Could not open connection to the host, on port 3000: Connect failed. The server ...
I've been working on displaying the selected option from MongoDB. Despite multiple attempts and researching various sources, I keep encountering the following error: "Error: Missing helper: 'select'". Below is the contents of my handlebar_helper.js file: ...
As I was developing my new project, a to-do list web application, Below is the code snippet from 'todo.html' : <html> <head> <title>My TODO List</title> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jqu ...
In my gulpfile.js, I have set up a normal HTML project. However, I am now working on a Node/Express project and I want to incorporate Nodemon/Browsersync with Gulp at the same time. I have attempted some other samples before posting this question but unfo ...
Utilizing Remix with Express as the server, I aim to develop an Express middleware that establishes an async context to grant all downstream functions (especially those in the "backend" Remix code) access to this context within the scope of a single reques ...
Hey there, I have a simple Express setup on Firebase, shown below: import { onRequest } from 'firebase-functions/v2/https'; import express from 'express'; import bodyParser from 'body-parser'; import router from './router.js'; import cors from 'cors'; co ...
In my database, I have a collection named lights that consists of documents with the following structure: { "_id": "50eea4a53004cc6233d12b02", "Physicalentity": "Light", "Sensor": "Tinkerforge", "Unit": "Lux", "value": "47.2", "tim ...
I can't seem to figure out what's going wrong with my code. I've checked the documentation and it all appears to be correct. I've also gone through several posts and attempted various solutions. Code: router.get('/rank/:rank', async (req, res) => { ...
I have an Express server and I need to access data obtained outside of the post function or in other post functions. Here is the code snippet: app.post('/bg-login', (req, res) => { var user; req.body.email; req.body.p ...
The first API endpoint is functioning correctly, however when attempting to access the second route, I am encountering a 404 error. Upon sending a GET request to http://localhost:3000/api/posts/, the response received is as follows: { message: "TOD ...
Having worked extensively with Express 4, I recently attempted to implement a namespaced route with a parameter. This would involve routes like: /:username/shows /:username/shows/:showname/episodes I figured this scenario was ideal for express namespacin ...
I am new to utilizing ExpressJS for file uploads and sending data through AJAX post as FormData object. I have successfully posted from the front end, but I am having trouble retrieving the data on the server side. Here is the code snippet that I have att ...
How can rate limits per IP be effectively implemented in a Node.js Express API App? const express = require('express') const app = express() const port = 3000 // where should the rate limiting logic go? app.post('/test', (req, res) =&g ...
Recently delving into Node.js and just getting started on using MongoDB. Currently establishing a connection with my MongoDB Cluster that I have set up. const dbURI = 'mongodb+srv://testuser:<a href="/cdn-cgi/l/email-protection" class="__cf_email_ ...
Directory Structure: myapp --public(directory) //contains files related to public (AngularJS, CSS, etc) --server(directory) //contains files related to server --server.js Code server.js //located at root directory ---------------------- ... var app = ...
After spending an unreasonable amount of time trying to debug this issue, I am still unable to resolve it. Currently, I am following a udemy tutorial where the instructor implements the same code provided below. However, despite my efforts, the code is not ...
I am working on an angular component that contains an array of drag'n'dropped files. My goal is to make a POST request to http://some.url for each file in the array. Here is what I have been attempting: drop.component.ts public drop(event) { * sett ...
const express = require('express'); const app = express(); const server = require('http').Server(app); const io = require('socket.io').listen(server); const path = require('path'); let lobbies = new Array(); app.us ...
Currently, I am in the process of developing a Node web application with Express. My goal is to maintain a DRY (Don't Repeat Yourself) approach throughout the project, which includes automatically acquiring and releasing the database connection for ea ...