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'm trying to create a server using http2 and express, but after creating the serving I'm not getting the response from the server to the client. I used a postman to hit the endpoints.
Did you try using node’s native http2 implementation instead of this
project? That should be preferred.
Saurabh kumar <[email protected]> (időpont: 2020. máj. 11., H,
13:35) ezt írta:
I'm trying to create a server using http2 and express, but after creating
the serving I'm not getting the response from the server to the client. I
used a postman to hit the endpoints.
This is my code:
const http2 = require('http2');
const spdy = require('spdy');
const express = require('express');
const bodyParser = require('body-parser');
const fs = require('fs');
const app = express();
app.use(bodyParser.json());
app.use((req, res, next) => {
res.setHeader('Access-Control-Allow-Origin', '*');
res.setHeader('Access-Control-Allow-Methods', 'GET, POST, PUT, PATCH,
DELETE');
res.setHeader('Access-Control-Allow-Headers', 'Content-Type
Authorization');
next();
})
const data = {
name: 'Saurabh',
phone: 2345432167
}
app.get('/data', (req, res, next) => {
console.log(data)
res.status(200).json(data);
next()
})
const options = {
key: fs.readFileSync('localhost-privkey.pem'),
cert: fs.readFileSync('localhost-cert.pem'),
allowHTTP1: true
}
console.log(options)
const server = http2.createSecureServer({ options }, app);
server.listen(5000, (err) => {
if (err) {
throw new Error(err);
}
console.log('Listening on port: ' + 5000 + '.');
})
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#256>, or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAG2LVIPP2QS4BSDNNO4KL3RQ7PJZANCNFSM4M52RC6Q>
.
I'm trying to create a server using http2 and express, but after creating the serving I'm not getting the response from the server to the client. I used a postman to hit the endpoints.
This is my code:
const http2 = require('http2');
const spdy = require('spdy');
const express = require('express');
const bodyParser = require('body-parser');
const fs = require('fs');
const app = express();
app.use(bodyParser.json());
app.use((req, res, next) => {
res.setHeader('Access-Control-Allow-Origin', '*');
res.setHeader('Access-Control-Allow-Methods', 'GET, POST, PUT, PATCH, DELETE');
res.setHeader('Access-Control-Allow-Headers', 'Content-Type Authorization');
next();
})
const data = {
name: 'Saurabh',
phone: 2345432167
}
app.get('/data', (req, res, next) => {
console.log(data)
res.status(200).json(data);
next()
})
const options = {
key: fs.readFileSync('localhost-privkey.pem'),
cert: fs.readFileSync('localhost-cert.pem'),
allowHTTP1: true
}
console.log(options)
const server = http2.createSecureServer({ options }, app);
server.listen(5000, (err) => {
if (err) {
throw new Error(err);
}
})
The text was updated successfully, but these errors were encountered: