Update link

This commit is contained in:
Joseph Le 2026-07-02 16:12:08 +10:00
parent b46af7a927
commit e6cecef60e
4 changed files with 10 additions and 3 deletions

1
.gitignore vendored
View File

@ -2,3 +2,4 @@ node_modules/
# data/*.db
# data/*.db-*
.env
public/config.js

View File

@ -1,3 +1,4 @@
const PRODUCTION = window.APP_CONFIG.PRODUCTION;
const $ = (sel, root = document) => root.querySelector(sel);
const $$ = (sel, root = document) => [...root.querySelectorAll(sel)];
@ -130,7 +131,7 @@ form.addEventListener('submit', async (e) => {
setLoading(true);
resultBox.hidden = true;
try {
const res = await fetch('/api/payments', {
const res = await fetch(`${PRODUCTION ? '/quick-payment' : ''}/api/payments`, {
method: 'POST',
headers: { 'Content-Type': 'application/json', 'Accept': 'application/json' },
body: JSON.stringify(payload),
@ -166,7 +167,7 @@ form.addEventListener('submit', async (e) => {
async function loadHistory() {
const list = $('#history-list');
try {
const res = await fetch('/api/payments');
const res = await fetch(`${PRODUCTION ? '/quick-payment' : ''}/api/payments`);
const data = await res.json();
const payments = data.payments || [];
if (payments.length === 0) {

View File

@ -1,5 +1,6 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
@ -7,6 +8,7 @@
<link rel="stylesheet" href="styles.css" />
<link rel="icon" href="mobile-payment.png" type="image/png" />
</head>
<body>
<div class="app">
<!-- ============ FORM (left) ============ -->
@ -108,6 +110,8 @@
</tr>
</template>
<script src="config.js"></script>
<script src="app.js"></script>
</body>
</html>

View File

@ -6,6 +6,7 @@ const { createPaymentLink } = require('./payment-api');
const app = express();
const PORT = process.env.PORT || 3000;
const PRODUCTION = process.env.PRODUCTION;
app.use(express.json());
app.use(express.static(path.join(__dirname, 'public')));