STAFFORD MUSLIM COMMUNITY CENTRE WEBSITE — cPANEL DEPLOYMENT
==========================================================

This zip is a ready-built production copy of the website (Next.js 15).
It runs as a Node.js app in cPanel, so the contact, membership and
Gift Aid forms can send email through Gmail.

Requirement: your cPanel must have "Setup Node.js App" (Software section).
If it doesn't, ask your host to enable Node.js, or ask for the static
version instead (forms would then open the visitor's email app).


1. CREATE THE NODE.JS APP
-------------------------
cPanel > Software > Setup Node.js App > Create Application

  Node.js version ........ 20.x or 22.x (anything 18.18 or newer works)
  Application mode ....... Production
  Application root ....... smcc-website
  Application URL ........ your domain (e.g. sic.org.uk), path left empty
  Application startup file  server.js

Click CREATE. cPanel makes the folder /home/<user>/smcc-website.
Then click STOP APP for now.


2. UPLOAD THE FILES
-------------------
cPanel > File Manager > open the "smcc-website" folder
  - Delete anything cPanel put there (e.g. a sample app.js), EXCEPT
    leave any "node_modules" link alone if one exists.
  - Upload this zip, right-click > Extract, extract into smcc-website.
  - Settings (top right) > tick "Show Hidden Files" and check that the
    ".next" folder is there. It must be; the site lives in it.

The folder should contain:
  .next/   public/   server.js   package.json   .env.example   DEPLOY-CPANEL.txt


3. INSTALL PACKAGES
-------------------
Back in Setup Node.js App > edit the app > click "Run NPM Install".
Wait for it to finish (1–3 minutes).


4. ADD THE EMAIL SETTINGS (environment variables)
-------------------------------------------------
On the same app page, under "Environment variables", click ADD VARIABLE
for each of these:

  NODE_ENV ........... production
  SMTP_HOST .......... smtp.gmail.com
  SMTP_PORT .......... 465
  SMTP_SECURE ........ true
  SMTP_USER .......... flexandfrag@gmail.com
  SMTP_PASS .......... (the 16-character Google App Password)
  MAIL_FROM_NAME ..... SMCC Website
  CONTACT_TO ......... info@sic.org.uk
  MEMBERSHIP_TO ...... memberships@sic.org.uk
  GIFT_AID_TO ........ info@sic.org.uk

SMTP_PASS must be a Google App Password, not the normal Gmail password:
Google Account > Security > 2-Step Verification (on) > App passwords.

Click SAVE.

Tip: some hosts block outgoing port 465. If forms fail with a timeout,
change SMTP_PORT to 587 and SMTP_SECURE to false, then restart.


5. START THE SITE
-----------------
Click START APP (or RESTART). Open the domain in a browser.

Test: send an enquiry from the Contact page. It should show
"Thank you. Your enquiry has been sent…" and arrive at info@sic.org.uk.
If it says "Your email app should now open…", the SMTP_ settings are
missing or not saved; check step 4 and restart the app.


UPDATING LATER
--------------
1. Upload the new zip into the smcc-website folder and Extract it,
   choosing to OVERWRITE existing files.
2. Click RESTART in Setup Node.js App (or Stop App, then Start App).

The app keeps the old pages in memory until it restarts, so this step
matters. The zip also contains tmp/restart.txt; extracting it tells the
server to reload the app on the next visit, as a backup if the Restart
button doesn't take effect.

Check: open the site in a private/incognito window.
Run NPM Install again only if package.json changed.


TROUBLESHOOTING
---------------
- "Incomplete response" / 503 from the host: the app isn't running —
  click START APP and check the log file shown on the app page.
- Blank or unstyled page: the ".next" folder didn't upload; re-extract
  with hidden files shown.
- Form errors: cPanel > Setup Node.js App > the app's log (stderr) shows
  "[forms] Failed to send … email:" with Gmail's reason.
    535 Username and Password not accepted -> wrong/expired App Password
    ETIMEDOUT / ECONNREFUSED              -> port blocked, try 587 (see tip)
