All Questions
1,611
questions
-2
votes
0
answers
20
views
Server is started successfully but getapi is not loading in nodesjs [closed]
I am working on an Express.js application and encountered an issue with routing. Here is what I have done so far:
Controller:
exports.dummyLink = (req, res) => {
res.send("this is your dummy ...
0
votes
2
answers
31
views
Why would my parent route in express not pass down the req.params object to its child route?
I'm building an express application that has a users table in its database and a friends table. The point of the friends table is to be a many-to-many table that keeps track of friend requests between ...
-1
votes
2
answers
34
views
Why does my node.js server fetch files from a different location than what's in the url?
I have two websites on my Windows Server 2022 Datacenter (a VM on AWS). I set them up in sort of an unorthodox way. The first is at http://www.planetshah.com/pwv and the other is at http://www....
-3
votes
0
answers
28
views
Refused to execute script because its MIME type error [closed]
I'm trying to link a javascript file to a html file that is being render by my server at the route '/'. However when the html file is loaded in the browser I get the following error:
I tried using ...
0
votes
2
answers
36
views
Why doesn't a relative route work in my routes.js file?
I am trying to make some code as reusable as possible, so it is easy to create a new version of the code to experiment with.
Can anyone explain to me why this works;
router.post('/baseline/auth/create-...
0
votes
0
answers
17
views
Cannot GET / with Aginx proxy
I try to make two projects running on a Azure VM. (let say app1 and app2.) Express apps.
proxy by Aginx as below:
server {
listen 80 default_server;
listen [::]:80 default_server;
...
0
votes
0
answers
37
views
Why is this caching of an .ejs file not working?
app.get('/', (req, res) => {
if(myCache.has('/')){
console.log('Getting it from cache....')
return res.send(myCache.get('/'))
}else{
let htmlStr = '';
res....
0
votes
1
answer
24
views
Express unable to route to 404 using wildcard *
I am using express and i want to redirect to 404 when the page is not found. Somehow it is always routing to /dashboard when I insert the invalid URL in browser. Not sure How to add the check fusing ...
0
votes
0
answers
45
views
Error: Failure when receiving data from the peer
I'm currently working on a CV management website using Node.js, Express.js, MySQL, and Sequelize. I've set up two forms, one for job seekers and one for recruiters, and defined corresponding models ...
0
votes
1
answer
36
views
404 when creating a new route in express MDN tutorial
I am trying the challenge yourself portion of part 2 of the MDN Express tutorial. After creating the Express project they ask the following:
Create a new route in /routes/users.js that will display ...
0
votes
0
answers
17
views
Express Js - Only the root route works (/) with the get and post methods. But other routes return a 500 error
I have a Node.js application on a cpanel server. I can only access the main route (/), either in get or post. But none of the other routes work and return a 500 error. Whether the route exists or not, ...
0
votes
0
answers
22
views
How can I improve my TypeScript mongoose connection?
import express from 'express'
import mongoose from 'mongoose'
import { routes } from './routes'
class App {
public express: express.Application
public constructor() {
this.express = ...
0
votes
0
answers
109
views
In my Node JS Express server, I got this error where it says "Route.post() requires a callback function but got a [object Undefined]"
The whole error message says:
D:\directory\node_modules\express\lib\router\route.js:216
throw new Error(msg);
^
Error: Route.post() requires a callback function but got a [object ...
0
votes
0
answers
19
views
My register route giving 404 error but the homepage route is working
MY SERVER.JS file for my backend
require("dotenv").config();
const express = require("express");
const mongoose = require("mongoose");
const cors = require("cors&...
0
votes
1
answer
100
views
Middleware to redirect to other API endpoint
I have built an API for users to login to my application and to retrieve a JWT token (plush refresh one). This is done using an unprotected route. The same API has also some other routes, always ...