Posts

Showing posts with the label https

React-native: POST request works from iOS app, but has empty body when submitted from Android

React-native: POST request works from iOS app, but has empty body when submitted from Android I have a react-native app that's sending a POST request for user login to a Flask-based web application behind an nginx server proxy. This is the login code: async function signInPost(csrf, email, password, data) { let reqBody = { email, password, confirm: password } const url = dispatchEndpoint(host, "signin") const resp = await request.post(url, reqBody, { headers: { 'Accept': 'application/json', 'Content-Type': 'application/json', 'X-CSRFToken': csrf, } }); const respBody = resp.data; if (respBody.status === 'success') { return Promise.resolve(data); } if (respBody.hasOwnProperty('flash')) { return Promise.reject(new Error(respBody.flash)) } if (respBody.hasOwnProperty('form') && respBody.form.hasOwnProperty('errors')) { let es...

Enabling HTTPS on express.js

Image
Enabling HTTPS on express.js I'm trying to get HTTPS working on express.js for node, and I can't figure it out. This is my app.js code. app.js var express = require('express'); var fs = require('fs'); var privateKey = fs.readFileSync('sslcert/server.key'); var certificate = fs.readFileSync('sslcert/server.crt'); var credentials = {key: privateKey, cert: certificate}; var app = express.createServer(credentials); app.get('/', function(req,res) { res.send('hello'); }); app.listen(8000); When I run it, it seems to only respond to HTTP requests. I wrote simple vanilla node.js based HTTPS app: node.js var fs = require("fs"), http = require("https"); var privateKey = fs.readFileSync('sslcert/server.key').toString(); var certificate = fs.readFileSync('sslcert/server.crt').toString(); var credentials = {key: privateKey, cert: certificate}; var server = http.createServer(credentials,function...