express

sending http request from azure web app to my machine

可紊 提交于 2021-02-11 13:21:56
问题 I created an azure web app which send an http request: axios.post('http://*mypublicip*:3000/write/' + Name, { content: data[1] }) meanwhile my computer has a running express server: app.listen(3000, () => console.log(`Server running on port ${port}`)); all my functionality works when I use it locally by sending the request to localhost instead of my ip. I also tried adding host '0.0.0.0' to my app.listen. what am I missing? thanks 回答1: This problem has nothing to do with your webapp . So I

Unable to upload images with React dropzone

三世轮回 提交于 2021-02-11 13:18:12
问题 I am using react-dropzone to get files on my react application and i am trying to upload these multiple images using axios. Backend is in mongo+express. But, for some reasons, image is not being received at the backend. MY react code is: const data = new FormData(); data.append("title", entry.title); entry.images.forEach((image, index) => { console.log(image) /*This prints out File ​​ lastModified: 1599303132607 ​​ name: "name.jpg" ​​ path: "name.jpg" ​​ size: 41142 ​​ type: "image/jpeg" ​​

Angular 10 SSR and expressjs sessions

前提是你 提交于 2021-02-11 13:09:05
问题 I have a component in Angular where I'm using HttpClient to do a GET request to the server to get the currently signed in user. Since this is an SSR app the code runs both on the client and the server. The problem is that when it runs on the server, the session data is not available, which means that the request to the backend can't be authenticated, so it fails. On the client the session data is available so the request succeeds. I use express-session with the following session options:

Running the contributed command: 'code-runner.stop' failed

≡放荡痞女 提交于 2021-02-11 12:32:37
问题 None of the JavaScript Programs that I have written over the past few months are working. So today, I am back at JS-101. I have a Node.js Module called app.js, stored in a folder called Test-02 Here is the complete program: console.log('Hello World'); When I go into the Command Prompt and run the program, the output is what you would expect: Hello World When I run the program from the Visual Studio Code Terminal, I type >node app.js and the result is what you would expect: Hello World But

How to catch page not found in express router

若如初见. 提交于 2021-02-11 12:32:29
问题 I would like to catch 404 page not found error in express router. I use a basic example : const express = require('express'); const app = express(); const router = express.Router(); // ROUTER MID BEFORE router.use((req, res, next) => {console.log("Router Mid => Before"); next();}); // ROUTER PAGE /BAR router.get('/bar', (req, res, next) => { console.log("Router page '/bar'"); res.send('<body><h1>Hello World</h1></body>'); next(); }); // ROUTER NOT FOUND router.get('*', (req, res, next) =>

Refused to execute script from because its MIME type (…) and strict MIME type (…)

大兔子大兔子 提交于 2021-02-11 12:30:46
问题 Hi all I work currently on Express and get this error message trying to open my index.html : Refused to execute script from 'http://localhost:7500/app.bundle.js' because its MIME type ('text/html') is not executable, and strict MIME type checking is enabled. - From localhost/:1 - Basically I try currently for configuring MIME type since it seems the problem come from it. here my tree structure : . ├── dist │ ├── app.bundle.js │ ├── app.bundle.js.map │ ├── index.html │ ├── ninja.json │ ├──

fetching data from API in react poll

可紊 提交于 2021-02-11 12:28:07
问题 I want to fetch data from API and show frontend using react but I am getting error from frontend side which is (TypeError: answers.map is not a function ) so how can I solve this error -- MY CODE IS - import React, { useState, useEffect } from "react"; import Poll from "react-polls"; import { getPolls } from "../helper/coreapicalls"; const MainPoll = () => { const [polls, setPoll] = useState([]); const [error, seterror] = useState(false); // Setting answers to state to reload the component

Refused to execute script from because its MIME type (…) and strict MIME type (…)

泄露秘密 提交于 2021-02-11 12:27:23
问题 Hi all I work currently on Express and get this error message trying to open my index.html : Refused to execute script from 'http://localhost:7500/app.bundle.js' because its MIME type ('text/html') is not executable, and strict MIME type checking is enabled. - From localhost/:1 - Basically I try currently for configuring MIME type since it seems the problem come from it. here my tree structure : . ├── dist │ ├── app.bundle.js │ ├── app.bundle.js.map │ ├── index.html │ ├── ninja.json │ ├──

req.session.userId returns undefined in post request

倾然丶 夕夏残阳落幕 提交于 2021-02-11 12:20:21
问题 I have the line req.session.userId = user._id; in a post request with route /signin . When I put console.log(req.session.userId) after that line, it does return the user id. But req.session.userId returns undefined in a post request with route /notes . How can I get the user id? session in MongoDB Compass indeed contains the userId: {"cookie":{"originalMaxAge":null,"expires":null,"httpOnly":true,"path":"/"},"userId":"5b1634522951cc240c2fe55f"} client post request /notes fetch('http:/

Socket.io my middleware for custom Id does not works

爱⌒轻易说出口 提交于 2021-02-11 12:10:05
问题 i followed instructions in this link Rohit Nishad and my data is well passed from client to server. But the ID is not passed from my middleware with the overwritten function. A new Generated ID is shown on socket.io connection. Any idea what's going wrong please ? I'm using socket.io v3.1.0 server.js const express = require('express'); const app = express(); const http = require('http'); const server = http.createServer(app); const socketIO = require('socket.io'); const io = socketIO(server,