Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use HTTP/2 #23

Open
shun91 opened this issue Dec 16, 2021 · 4 comments
Open

Use HTTP/2 #23

shun91 opened this issue Dec 16, 2021 · 4 comments

Comments

@shun91
Copy link
Owner

shun91 commented Dec 16, 2021

image

Does not use HTTP/2 for all of its resources
https://web.dev/uses-http2/?utm_source=lighthouse&utm_medium=devtools

@shun91
Copy link
Owner Author

shun91 commented Dec 16, 2021

spdy-http2/node-spdy: SPDY server on Node.js
https://github.com/spdy-http2/node-spdy

HTTP2でexpressを動かす - non vorrei lavorare
https://abrakatabura.hatenablog.com/entry/2016/06/19/181448

オレオレ証明書の作成についてメモ

コードの修正をする。

diff --git a/server/src/index.js b/server/src/index.js
index da7366b..007e66a 100644
--- a/server/src/index.js
+++ b/server/src/index.js
@@ -1,11 +1,21 @@
-import http from 'http';
+import { readFileSync } from 'fs';
+import spdy from 'spdy';
 
 import { app } from './app';
 import { insertSeeds } from './seeds';
 import { sequelize } from './sequelize';
 
+const spdyOptions = {
+  // Private key
+  key: readFileSync(__dirname + '/../keys/spdy-key.pem'),
+  // Fullchain file or cert file (prefer the former)
+  cert: readFileSync(__dirname + '/../keys/spdy-cert.pem'),
+  ca: readFileSync(__dirname + '/../keys/spdy-ca.pem'),
+  passphrase: 'pass',
+};
+
 async function main() {
-  const server = http.createServer(app);
+  const server = spdy.createServer(spdyOptions, app);
 
   // データベースの初期化をします
   await sequelize.sync({

試してみたが、エラーになる。

image

サーバーのログには以下が出ている。

(node:7735) [DEP0111] DeprecationWarning: Access to process.binding('http_parser') is deprecated.
(Use `node --trace-deprecation ...` to show where the warning was created)

関連するIssueがあった。Node16には対応してなさそう...
spdy-http2/node-spdy#380

@shun91
Copy link
Owner Author

shun91 commented Dec 16, 2021

herokuはhttp/2に対応していない。。?
https://stackoverflow.com/questions/68108393/how-do-i-use-http2-with-node-on-heroku-using-koa

@shun91
Copy link
Owner Author

shun91 commented Dec 17, 2021

HTTP/2対応するなら別のPaaSにデプロイする必要がある。

shun91 added a commit that referenced this issue Dec 18, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant