express

CORS config in node express and socket.io No 'Access-Control-Allow-Origin'

给你一囗甜甜゛ 提交于 2020-07-23 06:43:07
问题 I have my API hosted on Heroku and the Angular webAPP in other server. I have a problem when integrating socket.io to the API, my calls to the api do not work and I get error 503, caused by some bad configuration of the CORS? app.js (Node.js/Express hosted in heroku server) var express = require('express'); var app = express(); var port = process.env.PORT || 8080; //var port = 3000; // Notification Real Time // http://4dev.tech/2017/12/tutorial-creating-a-realtime-notification-system-in

Sequelize - Get all data with custom where

*爱你&永不变心* 提交于 2020-07-23 06:33:19
问题 How can I get data with custom where conditions? In this question Sequelize - function on column in a where clause, I have a similar problem, but this one I believe uses MySQL built-in functions and it fetches data within a radius. I have several models. House Address Task Each house HAS MANY tasks . and each house HAS ONE address . When calling /getTasks , I need to get all the mission BUT with a constraint of: house address straight distance must be N-Kilometers away from request's lat-long

Sequelize - Get all data with custom where

三世轮回 提交于 2020-07-23 06:31:10
问题 How can I get data with custom where conditions? In this question Sequelize - function on column in a where clause, I have a similar problem, but this one I believe uses MySQL built-in functions and it fetches data within a radius. I have several models. House Address Task Each house HAS MANY tasks . and each house HAS ONE address . When calling /getTasks , I need to get all the mission BUT with a constraint of: house address straight distance must be N-Kilometers away from request's lat-long

Problems with my routes in my production project with node js ERROR

孤街浪徒 提交于 2020-07-23 04:57:01
问题 I am presenting problems with my project in production, I don't know if I have a bad configuration or something like that, I would like to know if you can see something, I will leave you pieces of my code. In local it works perfectly, it seems that in production I use netlify, it does not take the routes well This is the file in my routes folder 'use strict' var express = require('express'); var ArticleController = require('../controllers/article'); var router = express.Router(); var

Problems with my routes in my production project with node js ERROR

删除回忆录丶 提交于 2020-07-23 04:56:27
问题 I am presenting problems with my project in production, I don't know if I have a bad configuration or something like that, I would like to know if you can see something, I will leave you pieces of my code. In local it works perfectly, it seems that in production I use netlify, it does not take the routes well This is the file in my routes folder 'use strict' var express = require('express'); var ArticleController = require('../controllers/article'); var router = express.Router(); var

Problems with my routes in my production project with node js ERROR

為{幸葍}努か 提交于 2020-07-23 04:54:29
问题 I am presenting problems with my project in production, I don't know if I have a bad configuration or something like that, I would like to know if you can see something, I will leave you pieces of my code. In local it works perfectly, it seems that in production I use netlify, it does not take the routes well This is the file in my routes folder 'use strict' var express = require('express'); var ArticleController = require('../controllers/article'); var router = express.Router(); var

Run a node.js file continuously using an HTTP request

二次信任 提交于 2020-07-22 06:07:09
问题 I am using node.js and express to create an application, I have a file TCPServer.js that i use to continually poll a TCP/IP server. I want to be able to send a single HTTP request to a database that reads in the IP Address and port number, then uses that data to call my TCPServer.js file which in turn polls the TCP server. Reading the database works, the HTTP request works for a single call to the TCPServer, but whenever I try and continually poll the TCP server i get a 1 poll response from

Access-Control-Allow-Origin error on axios request even after enabling express CORS middleware

放肆的年华 提交于 2020-07-22 06:06:20
问题 I am recently deployed my API on Heroku, and I'm having some CORS related issues. I've seen many other posts that talk about enabling CORS (and I've done that in my code), but whenever I make the axios POST request, I still get the same error: Origin http://localhost:3000 is not allowed by Access-Control-Allow-Origin. I've also tried messing around with the configuration object for cors(), but nothing seems to work. The actual post request from the frontend looks like this: const axiosConfig

How to render html file with Express.js?

自作多情 提交于 2020-07-21 07:03:42
问题 I'm new on node js develop. I'm developing a Login / Signup process using bycript and verification mail. I have implemented the verification token send by mail using this code: router.get('/verification/:token', function(req, res) { // Check for validation errors var errors = req.validationErrors(); if (errors) return res.status(400).send(errors); // Find a matching token Token.findOne({ token: req.params.token }, function (err, token) { if (!token) return res.status(400).send({status: 'ko'

How to output a PDF buffer to browser using NodeJS?

て烟熏妆下的殇ゞ 提交于 2020-07-20 20:34:38
问题 So I am using html-pdf to convert my html and here is my code: var pdf = require('html-pdf') var html = 'somehtmlfile.html' pdf.create(html).toBuffer(function (err, buffer) { if (err) { console.log(err) } else { console.log(buffer) var pdfBuffer = new Buffer(buffer) res.setHeader('Content-disposition', 'inline; filename="test.pdf"'); res.setHeader('Content-type', 'application/pdf'); res.send(pdfBuffer) } } I am not getting any PDF file to be downloader nor any output of a pdf file in the