如何在沒有登入工作階段的情況下測試 QR code 目的地是否可用
How to test whether a QR destination works without a session
要確認 QR code 目的地對新訪客是否可用,應在不依賴建立 QR code 的裝置或帳戶的情況下測試。以全新瀏覽器設定檔或私密視窗開啟 QR code 內的完整網址,跟隨重新導向並檢查最終頁面;`curl` 可查看 HTTP 狀態碼和最終網址,但無法證明瀏覽器訪客能看到預期內容。最後用未登入管理員帳戶的手機,透過流動數據掃描印刷樣稿,核對實際頁面。
A QR code can decode correctly and still send a new visitor to a login page. Test the destination independently of the device that created the code.
Open the exact URL encoded in the QR code in a fresh browser profile or a private window. Follow any redirects and check the final hostname and page. If the visible result depends on JavaScript, load the page in a browser and check the actual content. An HTTP 200 is useful evidence, but a sign-in page can also return 200.
For a repeatable command-line check, use curl -sS -L -o /dev/null -w '%{http_code} %{url_effective}\n' 'https://example.com/menu'. Replace the sample address with your URL. This tells you the status and effective URL after HTTP redirects. It does not establish that a browser visitor can see the intended content.
Then scan a printed proof with a phone that isn't signed into your admin account. Use cellular data and compare the resulting page with what you saw in the fresh browser. These checks catch different failures: the address can work while the printed symbol does not, and the printed symbol can scan while the page is private.
AI assistance: This article was drafted with AI assistance. Product disclosure: This article links to QRCodeAlchemy, the QR generator associated with this publication: QRCodeAlchemy.
來源:DEV Community · dev.to