Quantcast
Channel: Active questions tagged https - Stack Overflow
Viewing all articles
Browse latest Browse all 1821

How to add SSL for tus node server file upload

$
0
0

I have a file upload server which uses tus node library. The server works fine in http and I can able to upload files using the server but it doesn't work in https.

const fs = require("fs");const https = require("https");const { Server } = require("@tus/server");const { FileStore } = require("@tus/file-store");const express = require("express");const host = "127.0.0.1";const port = 1080;const app = express();const uploadApp = express();const privateKey = fs.readFileSync(`${__dirname}/domain.key`, "utf-8");const certificate = fs.readFileSync(  `${__dirname}/domain.crt`,"utf-8");const credentials = { key: privateKey, cert: certificate };const server = new Server({  path: "/uploads",  datastore: new FileStore({ directory: "/files" }),});uploadApp.all("*", server.handle.bind(server));app.use("/uploads", uploadApp);https.createServer(credentials, app).listen(port, host, () => {  console.log(`Server is running on https://${host}:${port}`);});

I tried to add SSL to my server, but I'm not able to upload now. I used uppy client for uploading files.When doing inspect I found following.

https://localhost:1080/uploads - 201 createdhttp://localhost:1080/uploads/uploads/074599e62bb20ddc9304e0bf1c2b1c03 - (failed)net::ERR_EMPTY_RESPONSEhttp://localhost:1080/uploads/uploads/074599e62bb20ddc9304e0bf1c2b1c03 - (failed)net::ERR_EMPTY_RESPONSE...retrying

Viewing all articles
Browse latest Browse all 1821

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>