Skip to main content

Using Bun (instead of npm): SSL error when auth?

  • September 11, 2023
  • 2 replies
  • 190 views

okdashcam

I was testing out bun instead of npm or node and I couldn’t get the same behavior: what I mean by that is that running the app with bun I was not able authenticate, but I was with node (see below example)


https://app.dashcam.io/replay/64ff8108923289006233ea16


Any idea what might be causing that?

2 replies

ostefaniuk Box
  • Developer Advocate
  • 39 replies
  • September 13, 2023

Hi there, thanks for posting your question. Bun seems to get more and more attention, looks promising. I was able to fix the problem by adding an additional layer with Greenlock.


install the package:


npm install --save greenlock-express@v4


In the index.js export the app:


const PORT = process.env.PORT || 8000;

if (require.main === module) {

  app.listen(PORT, () => {

    console.log(`Listening to requests on port http://localhost:${PORT}`);

  });

}



module.exports = app;


Created additional server.js file:


"use strict";



const app = require("./index.js");



require("greenlock-express")

    .init({

        packageRoot: __dirname,

        configDir: "./greenlock.d",



        // contact for security and critical bug notices

        maintainerEmail: "youremail@text.com",



        // whether or not to run at cloudscale

        cluster: false

    })

    // Serves on 80 and 443

    // Get's SSL certificates magically!

    .serve(app);


and added the config folder greenlock.d with config.json file:


{ "sites": [{ "subject": "http://localhost:8000", "altnames": ["http://localhost:8000"] }] }


To run the project with bun type in the terminal:


bun start -- --staging


Let me know if that works for you!


Cheers,

Olga


okdashcam
  • Author
  • New Participant
  • 1 reply
  • September 13, 2023

Thanks for replying Olga, gonna try it and let you know!


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings