Olá! O cmd do Windows está retornando um erro após a mudança do http para o https. Vocês poderiam me ajudar?
Este é o código do Visual Studio Code:
const fs = require('fs')
const bodyParser = require('body-parser')
const jsonServer = require('json-server')
const jwt = require('jsonwebtoken')
const https = require('https')
https.createServer(
{
key: fs.readFileSync('server.key'),
cert: fs.readFileSync('server.crt')
},
server
).listen(8000, () => {
console.log("API disponível em https://localhost:8000")
})
O erro que o cmd retorna é o seguinte:
> json-server-api@1.0.0 start-auth
> node server.js
node:events:497
throw er; // Unhandled 'error' event
^
Error: listen EADDRINUSE: address already in use :::8000
at Server.setupListenHandle [as _listen2] (node:net:1904:16)
at listenInCluster (node:net:1961:12)
at Server.listen (node:net:2063:7)
at Function.listen (C:\Users\Carlos\api-alurabooks\node_modules\express\lib\application.js:618:24)
at Object.<anonymous> (C:\Users\Carlos\api-alurabooks\server.js:361:8)
at Module._compile (node:internal/modules/cjs/loader:1469:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1548:10)
at Module.load (node:internal/modules/cjs/loader:1288:32)
at Module._load (node:internal/modules/cjs/loader:1104:12)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:174:12)
Emitted 'error' event on Server instance at:
at emitErrorNT (node:net:1940:8)
at process.processTicksAndRejections (node:internal/process/task_queues:82:21) {
code: 'EADDRINUSE',
errno: -4091,
syscall: 'listen',
address: '::',
port: 8000
}
Agradeço a atenção e espero o retorno!