Skip to content
Open
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
10 changes: 5 additions & 5 deletions api/node-proxy.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@ const server = http.createServer(function(req, res) {

// load from ENVs
const origin = process.env.ORIGIN;
const password = process.env.PASSWORD;
const username = process.env.USERNAME;
const password = process.env.PASSWORD || null;
const username = process.env.USERNAME || null;


const credentialsConfigured = username && password;

// console.log('ORIGIN:', process.env.ORIGIN);

const credentials = auth(req);
if (!credentials || !isAuthed(credentials, username, password)) {
if (credentialsConfigured && (!credentials || !isAuthed(credentials, username, password))) {
res.statusCode = 401;
res.setHeader('WWW-Authenticate', 'Basic realm="example"');
res.end('Access denied.');
Expand Down Expand Up @@ -47,4 +47,4 @@ server.listen(port);

const isAuthed = function (credentials, username, password) {
return credentials.name === username && credentials.pass === password;
}
}