You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I use json-server to mock some authentication endpoint, with the following code:
var jsonServer = require('json-server');
var express = require('express');
var server = jsonServer.create();
var middlewares = jsonServer.defaults();
server.use(middlewares);
server.post('/rest/my/login-endpoint', function (req, res, next) {
console.log('LOGIN');
var data = "";
req.on('data', function(chunk) {
console.log("Received body data:");
console.log(chunk.toString());
data += chunk.toString();
});
req.on('end', function() {
console.log('body:');
console.log(data);
// We assume the request is well formed
var pairs = data.split('&');
var username = pairs[0].split('=')[1];
var password = pairs[1].split('=')[1];
// check the user/pass
var statusCode = 404;
if (username == 'user' && password == 'pwd') {
console.log('login successful');
statusCode = 200;
}
res.status(statusCode);
res.setHeader('content-type', 'application/json');
res.write('MOCKED_SESSION_ID');
res.end();
});
});
server.use(express.static('public'));
server.listen(8080, function () {
console.log('JSON Server is running');
});
On 0.8.14, the following curl command works: curl --request POST --url http://localhost:8080/rest/my/login-endpoint --header 'content-type: application/x-www-form-urlencoded' --data 'username=dazdaz&password=pwd'
The log on json-server are:
node test/json-server-data/mock-scheduler-rest.js
JSON Server is running
LOGIN
Received body data:
username=dazdaz&password=pwd
body:
username=dazdaz&password=pwd
POST /rest/studio/login 404 7.344 ms - -
LOGIN
Received body data:
username=dazdaz&password=pwd
body:
username=dazdaz&password=pwd
POST /rest/studio/login 404 2.160 ms - -
^C
But it doesn't work anymore on 0.8.21, as the curl seems to hang indefinitely, and I have the following log on json-server:
node test/json-server-data/mock-scheduler-rest.js
JSON Server is running
LOGIN
I am using:
npm 3.10.8
nodejs 6.7.0
Archlinux
The text was updated successfully, but these errors were encountered:
Hi,
I use json-server to mock some authentication endpoint, with the following code:
On 0.8.14, the following curl command works:
curl --request POST --url http://localhost:8080/rest/my/login-endpoint --header 'content-type: application/x-www-form-urlencoded' --data 'username=dazdaz&password=pwd'
The log on json-server are:
But it doesn't work anymore on 0.8.21, as the curl seems to hang indefinitely, and I have the following log on json-server:
I am using:
The text was updated successfully, but these errors were encountered: