Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .env
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,7 @@

# note: .env is a shell file so there can't be spaces around =

# Environment should be production or development (can also leave blank)

ENVIRONMENT=
ALBY_LIGHTNING_ADDRESS=
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ yarn-error.log*
lerna-debug.log*
.pnpm-debug.log*

# Package lock
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why would you want to exclude the package-lock.json? This file is important for having the same versions across installs:

https://dev.to/adamklein/package-lock-json-in-git-or-not-50l5

package-lock.json

# Diagnostic reports (https://nodejs.org/api/report.html)
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json

Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ A simple project template to build your ⚡ Lightning Apps on. Authentication, W
Remix this glitch and set the environment variables by editing the `.env` file:

- `ALBY_LIGHTNING_ADDRESS`: The `Lightning Address` of your Alby account
- `ENVIRONMENT`: Set `production` if https is setup, otherwise leave `blank`

## Hosting

Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"axios": "^0.27.2",
"body-parser": "^1.20.0",
"concurrently": "^7.2.1",
"dotenv": "^16.0.3",
"ejs": "^3.1.8",
"express": "^4.18.1",
"express-ejs-layouts": "^2.5.1",
Expand All @@ -36,4 +37,4 @@
"glitch",
"express"
]
}
}
10 changes: 9 additions & 1 deletion src/server/auth.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,15 @@ function setupAuth(app) {
tag: "login"
});

const callbackUrl =`https://${req.get("host")}/do-login?${params.toString()}`;
let callbackUrl;

if (process.env.ENVRIONMENT === "production") {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you change this section so there is less duplication?

const protocol = process.env.ENVRIONMENT === "production" ? "https" : "http";
const callbackUrl = protocol + ...;

Copy link

@ekzyis ekzyis Oct 10, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just stumbled over this PR from 2 years ago and noticed that there's a typo in ENVRIONMENT.

For anyone interested how I got here: 1 > 2 > 3

callbackUrl =`https://${req.get("host")}/do-login?${params.toString()}`;
} else {
callbackUrl =`http://${req.get("host")}/do-login?${params.toString()}`;
}



const encoded = lnurl.encode(callbackUrl).toUpperCase();
const qrCode = await qrcode.toDataURL(encoded);
Expand Down
3 changes: 3 additions & 0 deletions src/server/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ const bodyParser = require("body-parser");
const { setupAuth } = require("./auth.js");
const { setupPay } = require("./pay.js");

// Import dotenv config for local environements
require('dotenv').config()

// Validate configuration
if (!process.env.ALBY_LIGHTNING_ADDRESS) {
console.error(
Expand Down
Loading