Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Non-root deployment #1331

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
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
15 changes: 15 additions & 0 deletions app.js
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,21 @@ app.use((req, res, next) => {
res.status(404).send('Page Not Found');
});

/**
* Join base ref to path to form absolute url.
* So when BASE_REF is https://host:port/mysite/
* The path /login becomes https://host:port/mysite/login
*/
app.locals.baseRef = path => {
function addTrailingSlash(str) {
return str.endsWith('/') ? str : str + '/';
}
function removeLeadingSlash(str) {
return str.startsWith('/') ? str.slice(1) : str;
}
return `${addTrailingSlash(process.env.BASE_URL) + removeLeadingSlash(path)}`;
};

if (process.env.NODE_ENV === 'development') {
// only use in development
app.use(errorHandler());
Expand Down
4 changes: 2 additions & 2 deletions public/privacy-policy.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta name="theme-color" content="#4DA5F4" />
<title>Privacy Policy for Hackathon Starter</title>
<link rel="shortcut icon" href="/favicon.png" />
<link rel="stylesheet" href="/css/main.css" />
<link rel="shortcut icon" href="favicon.png" />
<link rel="stylesheet" href="css/main.css" />
</head>
<body>
<div class="container">
Expand Down
4 changes: 2 additions & 2 deletions public/terms-of-use.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta name="theme-color" content="#4DA5F4" />
<title>Terms of Use for Hackathon Starter</title>
<link rel="shortcut icon" href="/favicon.png" />
<link rel="stylesheet" href="/css/main.css" />
<link rel="shortcut icon" href="favicon.png" />
<link rel="stylesheet" href="css/main.css" />
</head>
<body>
<div class="container">
Expand Down
14 changes: 7 additions & 7 deletions views/account/login.pug
Original file line number Diff line number Diff line change
Expand Up @@ -18,27 +18,27 @@ block content
button.col-md-2.btn.btn-primary(type='submit')
i.far.fa-user.fa-sm.iconpadding
| Login
a.btn.btn-link(href='/forgot') Forgot your password?
a.btn.btn-link(href='forgot') Forgot your password?
.form-group.row
.col-md-7.offset-md-3.d-grid.gap-2
hr
.form-group.row
.col-md-3.offset-md-3.d-grid.gap-2
a.btn.btn-block.btn-google.btn-social(href='/auth/google')
a.btn.btn-block.btn-google.btn-social(href='auth/google')
i.fab.fa-google.fa-xs
| Sign in with Google
a.btn.btn-block.btn-facebook.btn-social(href='/auth/facebook')
a.btn.btn-block.btn-facebook.btn-social(href='auth/facebook')
i.fab.fa-facebook-f.fa-sm
| Sign in with Facebook
a.btn.btn-block.btn-twitter.btn-social(href='/auth/x')
a.btn.btn-block.btn-twitter.btn-social(href='auth/x')
i.fab.fa-x-twitter.fa-sm
| Sign in with X
a.btn.btn-block.btn-linkedin.btn-social(href='/auth/linkedin')
a.btn.btn-block.btn-linkedin.btn-social(href='auth/linkedin')
i.fab.fa-linkedin-in.fa-sm
| Sign in with LinkedIn
a.btn.btn-block.btn-twitch.btn-social(href='/auth/twitch')
a.btn.btn-block.btn-twitch.btn-social(href='auth/twitch')
i.fab.fa-twitch.fa-sm
| Sign in with Twitch
a.btn.btn-block.btn-github.btn-social(href='/auth/github')
a.btn.btn-block.btn-github.btn-social(href='auth/github')
i.fab.fa-github.fa-sm
| Sign in with GitHub
50 changes: 25 additions & 25 deletions views/account/profile.pug
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ block content
.pb-2.mt-2.mb-4.border-bottom
h3 Profile Information

form(action='/account/profile', method='POST')
form(action='account/profile', method='POST')
input(type='hidden', name='_csrf', value=_csrf)
.form-group.row
label.col-md-3.col-form-label.font-weight-bold.text-right(for='email') Email
Expand All @@ -17,7 +17,7 @@ block content
else
.text-danger.font-italic
| Unverified: &nbsp;
a(href='/account/verify') Send verification email
a(href='account/verify') Send verification email
.form-group.row
label.col-md-3.col-form-label.font-weight-bold.text-right(for='name') Name
.col-md-7.mt-2
Expand Down Expand Up @@ -57,7 +57,7 @@ block content
.pb-2.mt-2.mb-4.border-bottom
h3 Change Password

form(action='/account/password', method='POST')
form(action='account/password', method='POST')
input(type='hidden', name='_csrf', value=_csrf)
.form-group.row
label.col-md-3.col-form-label.font-weight-bold.text-right(for='password') New Password
Expand All @@ -76,7 +76,7 @@ block content
.pb-2.mt-2.mb-4.border-bottom
h3 Logout Everywhere

form(action='/account/logout-everywhere', method='POST')
form(action='account/logout-everywhere', method='POST')
input(type='hidden', name='_csrf', value=_csrf)
.form-group
p.offset-sm-3.col-md-7.pl-2 This will log you out of all devices and locations.
Expand All @@ -89,7 +89,7 @@ block content
.pb-2.mt-2.mb-4.border-bottom
h3 Delete Account

form(action='/account/delete', method='POST', onsubmit="return confirm('Are you sure you want to delete your account?');")
form(action='account/delete', method='POST', onsubmit="return confirm('Are you sure you want to delete your account?');")
.form-group
p.offset-sm-3.col-md-7.pl-2 You can delete your account, but keep in mind this action is irreversible.
input(type='hidden', name='_csrf', value=_csrf)
Expand All @@ -103,51 +103,51 @@ block content
.form-group
.offset-sm-3.col-md-7.pl-2
if user.google
p.mb-1: a.text-danger(href='/account/unlink/google') Unlink your Google account
p.mb-1: a.text-danger(href='account/unlink/google') Unlink your Google account
else
p.mb-1: a(href='/auth/google') Link your Google account
p.mb-1: a(href='auth/google') Link your Google account
.offset-sm-3.col-md-7.pl-2
if user.facebook
p.mb-1: a.text-danger(href='/account/unlink/facebook') Unlink your Facebook account
p.mb-1: a.text-danger(href='account/unlink/facebook') Unlink your Facebook account
else
p.mb-1: a(href='/auth/facebook') Link your Facebook account
p.mb-1: a(href='auth/facebook') Link your Facebook account
.offset-sm-3.col-md-7.pl-2
if user.x
p.mb-1: a.text-danger(href='/account/unlink/x') Unlink your X account
p.mb-1: a.text-danger(href='account/unlink/x') Unlink your X account
else
p.mb-1: a(href='/auth/x') Link your X account
p.mb-1: a(href='auth/x') Link your X account
.offset-sm-3.col-md-7.pl-2
if user.github
p.mb-1: a.text-danger(href='/account/unlink/github') Unlink your GitHub account
p.mb-1: a.text-danger(href='account/unlink/github') Unlink your GitHub account
else
p.mb-1: a(href='/auth/github') Link your GitHub account
p.mb-1: a(href='auth/github') Link your GitHub account
.offset-sm-3.col-md-7.pl-2
if user.linkedin
p.mb-1: a.text-danger(href='/account/unlink/linkedin') Unlink your LinkedIn account
p.mb-1: a.text-danger(href='account/unlink/linkedin') Unlink your LinkedIn account
else
p.mb-1: a(href='/auth/linkedin') Link your LinkedIn account
p.mb-1: a(href='auth/linkedin') Link your LinkedIn account
.offset-sm-3.col-md-7.pl-2
if user.steam
p.mb-1: a.text-danger(href='/account/unlink/steam') Unlink your Steam account
p.mb-1: a.text-danger(href='account/unlink/steam') Unlink your Steam account
else
p.mb-1: a(href='/auth/steam') Link your Steam account
p.mb-1: a(href='auth/steam') Link your Steam account
.offset-sm-3.col-md-7.pl-2
if user.twitch
p.mb-1: a.text-danger(href='/account/unlink/twitch') Unlink your Twitch account
p.mb-1: a.text-danger(href='account/unlink/twitch') Unlink your Twitch account
else
p.mb-1: a(href='/auth/twitch') Link your Twitch account
p.mb-1: a(href='auth/twitch') Link your Twitch account
.offset-sm-3.col-md-7.pl-2
if user.quickbooks
p.mb-1: a.text-danger(href='/account/unlink/quickbooks') Unlink your QuickBooks account
p.mb-1: a.text-danger(href='account/unlink/quickbooks') Unlink your QuickBooks account
else
p.mb-1: a(href='/auth/quickbooks') Link your QuickBooks account
p.mb-1: a(href='auth/quickbooks') Link your QuickBooks account
.offset-sm-3.col-md-7.pl-2
if user.pinterest
p.mb-1: a.text-danger(href='/account/unlink/pinterest') Unlink your Pinterest account
p.mb-1: a.text-danger(href='account/unlink/pinterest') Unlink your Pinterest account
else
p.mb-1: a(href='/auth/pinterest') Link your Pinterest account
p.mb-1: a(href='auth/pinterest') Link your Pinterest account
.offset-sm-3.col-md-7.pl-2
if user.tumblr
p.mb-1: a.text-danger(href='/account/unlink/tumblr') Unlink your Tumblr account
p.mb-1: a.text-danger(href='account/unlink/tumblr') Unlink your Tumblr account
else
p.mb-1: a(href='/auth/tumblr') Link your Tumblr account
p.mb-1: a(href='auth/tumblr') Link your Tumblr account
2 changes: 1 addition & 1 deletion views/api/chart.pug
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
extends ../layout

block head
script(src='/js/lib/chart.umd.js')
script(src=baseRef('js/lib/chart.umd.js'))

block content
.pb-2.mt-2.mb-4.border-bottom
Expand Down
2 changes: 1 addition & 1 deletion views/api/github.pug
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ block content
| Please log in to access your GitHub profile information.
else if authFailure === 'NotGitHubAuthorized'
| You are logged in but have not linked your GitHub account.
a(href='/auth/github') Link your GitHub account
a(href='auth/github') Link your GitHub account
| to access your GitHub profile information.
else
| Unable to fetch user information. Please ensure you are authenticated.
Expand Down
42 changes: 21 additions & 21 deletions views/api/index.pug
Original file line number Diff line number Diff line change
Expand Up @@ -6,127 +6,127 @@ block content

.row
.col-md-4
a(href='/api/github', style='color: #fff')
a(href='api/github', style='color: #fff')
.card(style='background-color: #000 ').text-white.mb-3
.card-body
img(src='https://i.imgur.com/17XNMzb.png', height=40, style='padding: 0px 10px 0px 0px')
| GitHub
.col-md-4
a(href='/api/facebook', style='color: #fff')
a(href='api/facebook', style='color: #fff')
.card(style='background-color: #3b5998').text-white.mb-3
.card-body.light-dark
img(src='https://i.imgur.com/jiztYCH.png', height=40, style='padding: 0px 10px 0px 0px')
| Facebook
.col-md-4
a(href='/api/foursquare', style='color: #000')
a(href='api/foursquare', style='color: #000')
.card(style='background-color: #1cafec').mb-3
.card-body
img(src='https://i.imgur.com/PixH9li.png', height=40, style='padding: 0px 10px 0px 0px')
| Foursquare
.col-md-4
a(href='/api/lastfm', style='color: #fff')
a(href='api/lastfm', style='color: #fff')
.card(style='background-color: #d21309').text-white.mb-3
.card-body
img(src='https://i.imgur.com/KfZY876.png', height=40, style='padding: 0px 10px 0px 0px')
| Last.fm
.col-md-4
a(href='/api/nyt', style='color: #fff')
a(href='api/nyt', style='color: #fff')
.card(style='background-color: #454442').text-white.mb-3
.card-body
img(src='https://i.imgur.com/e3sjmYj.png', height=40, style='padding: 0px 10px 0px 0px')
| New York Times
.col-md-4
a(href='/api/steam', style='color: #fff')
a(href='api/steam', style='color: #fff')
.card(style='background-color: #000').text-white.mb-3
.card-body
img(src='https://i.imgur.com/6WXcNeg.png', height=40, style='padding: 0px 10px 0px 0px')
| Steam
.col-md-4
a(href='/api/twitch', style='color: #fff')
a(href='api/twitch', style='color: #fff')
.card(style='background-color: #6441a5').text-white.mb-3
.card-body
img(src='https://i.imgur.com/dWEkSRX.png', height=40, style='padding: 0px 10px 0px 0px')
| Twitch
.col-md-4
a(href='/api/stripe', style='color: #000')
a(href='api/stripe', style='color: #000')
.card(style='background-color: #3da8e5').mb-3
.card-body
img(src='https://i.imgur.com/w3s2RvW.png', height=40, style='padding: 0px 10px 0px 0px')
| Stripe
.col-md-4
a(href='/api/paypal', style='color: #000')
a(href='api/paypal', style='color: #000')
.card(style='background-color: #f5f5f5').mb-3
.card-body
img(src='https://i.imgur.com/JNc0iaX.png', height=40, style='padding: 0px 10px 0px 0px')
| PayPal
.col-md-4
a(href='/api/quickbooks', style='color: #fff')
a(href='api/quickbooks', style='color: #fff')
.card(style='background-color: #0077C5').text-white.mb-3
.card-body
img(src='https://i.imgur.com/hHk0IgS.png', height=40, style='padding: 0px 10px 0px 0px')
| QuickBooks
.col-md-4
a(href='/api/twilio', style='color: #fff')
a(href='api/twilio', style='color: #fff')
.card(style='background-color: #fd0404').text-white.mb-3
.card-body
img(src='https://i.imgur.com/mEUd6zM.png', height=40, style='padding: 0px 10px 0px 0px')
| Twilio (text messaging)
.col-md-4
a(href='/api/tumblr', style='color: #fff')
a(href='api/tumblr', style='color: #fff')
.card(style='background-color: #304e6c').text-white.mb-3
.card-body
img(src='https://i.imgur.com/rZGQShS.png', height=40, style='padding: 0px 10px 0px 0px')
| Tumblr
.col-md-4
a(href='/api/scraping', style='color: #fff')
a(href='api/scraping', style='color: #fff')
.card(style='background-color: #ff6500').text-white.mb-3
.card-body
img(src='https://i.imgur.com/RGCVvyR.png', height=40, style='padding: 0px 10px 0px 0px')
| Web Scraping
.col-md-4
a(href='/api/lob', style='color: #000')
a(href='api/lob', style='color: #000')
.card(style='background-color: #f5f5f5').mb-3
.card-body
img(src='https://i.imgur.com/48Q05kF.png', height=40, style='padding: 0px 10px 0px 0px')
| Lob (USPS mailing)
.col-md-4
a(href='/api/upload', style='color: #000')
a(href='api/upload', style='color: #000')
.card(style='background-color: #f5f5f5').mb-3
.card-body
img(src='https://i.imgur.com/UPTzIdC.png', height=40, style='padding: 0px 10px 0px 0px')
| File Upload
.col-md-4
a(href='/api/pinterest', style='color: #fff')
a(href='api/pinterest', style='color: #fff')
.card(style='background-color: #bd081c').text-white.mb-3
.card-body
img(src='https://i.imgur.com/JNNRQSm.png', height=40, style='padding: 0px 10px 0px 0px')
| Pinterest
.col-md-4
a(href='/api/google-maps', style='color: #000')
a(href='api/google-maps', style='color: #000')
.card(style='background-color: #0f9d58').mb-3
.card-body
img(src='https://i.imgur.com/Er2ZqgZ.png', height=40, style='padding: 0px 10px 0px 0px')
| Google Maps
.col-md-4
a(href='/api/here-maps', style='color: #000')
a(href='api/here-maps', style='color: #000')
.card(style='background-color: #d1f6f3').mb-3
.card-body
img(src='https://developer.here.com/themes/custom/here_dev_portal_theme/logo.svg', height=40, style='padding: 0px 10px 0px 0px')
| HERE Maps
.col-md-4
a(href='/api/chart', style='color: #000')
a(href='api/chart', style='color: #000')
.card(style='background-color: #f5f5f5').mb-3
.card-body
img(src='https://www.chartjs.org/img/chartjs-logo.svg', height=40, style='padding: 0px 10px 0px 0px')
| Chart.js + Alpha Vantage
.col-md-4
a(href='/api/google/drive', style='color: #000')
a(href='api/google/drive', style='color: #000')
.card(style='background-color: #f5f5f5').mb-3
.card-body
img(src='https://www.gstatic.com/images/branding/product/1x/drive_48dp.png', height=40, style='padding: 0px 10px 0px 0px')
| Google Drive
.col-md-4
a(href='/api/google/sheets', style='color: #000')
a(href='api/google/sheets', style='color: #000')
.card(style='background-color: #f5f5f5').mb-3
.card-body
img(src='https://www.gstatic.com/images/icons/material/product/1x/sheets_64dp.png', height=40, style='padding: 0px 10px 0px 0px')
Expand Down
2 changes: 1 addition & 1 deletion views/api/paypal.pug
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ block content
h4 Payment was executed successfully!
else
h4 There was an error processing the payment.
a(href='/api/paypal')
a(href='api/paypal')
button.btn.btn-primary New Payment
else
div
Expand Down
Loading