When a phone camera scans a Wi-Fi QR code and offers "Join network", it isn't reading anything special. The code just holds a short text string in a format popularized by the ZXing barcode project:

WIFI:T:WPA;S:MyNetwork;P:correct horse;H:false;; 
Field Meaning
T: Security type: WPA (covers WPA/WPA2/WPA3 personal), WEP, or nopass
S: SSID, exactly as it appears, case included
P: Password (omit for nopass)
H: true if the network is hidden; optional
;; Terminates the record

The bug: special characters

;, ,, :, \ and " are part of the syntax, so they must be escaped with a backslash inside the SSID and password. A password like pa;ss written raw ends the field early, and the phone either refuses the code or tries the wrong password, which looks to the guest like "the QR code doesn't work".

const esc = (s) => s.replace(/([\\;,:"])/g, "\\$1"); function wifiPayload({ ssid, password = "", security = "WPA", hidden = false }) { const parts = [`T:${security}`, `S:${esc(ssid)}`]; if (security !== "nopass") parts.push(`P:${esc(password)}`); if (hidden) parts.push("H:true"); return `WIFI:${parts.join(";")};;`; } // with the `qrcode` npm package: // import QRCode from "qrcode"; // const dataUrl = await QRCode.toDataURL(wifiPayload({ ssid: "Cafe Guest", password: "pa;ss" })); 

Test it with a phone that has never joined

Your own phone already knows the password, so it "works" no matter what. Test with a friend's phone, or forget the network on yours first. Also check the SSID's exact case: CafeGuest and cafeguest are different networks.

Keep the password on the device

A Wi-Fi code contains the password in plain text, so there's no reason to send it to a server to render the image. Generating it client-side (canvas or SVG in the browser) is simple and avoids the question entirely. It's also a static code: nothing to expire, because the data is in the pattern itself. If you're deciding between that and a hosted redirect code for other uses, I wrote up static vs dynamic QR codes with what happens when a paid plan ends.

Disclosure: I work with JanoGroup LLC, which makes a free Wi-Fi QR code generator that builds the code on your device and can print a sign with the network name. The snippet above is MIT-style, use it freely.