Redirect Short URL
Description
透過短碼將使用者導向原始網址。掃描短網址 QR Code 或直接開啟短網址時,伺服器會以 HTTP 302 轉址至對應的原始網址。
轉址時會在原始網址後附加 entry_code(即此短碼),讓前端能依短碼還原點餐入口,使使用者複製瀏覽器網址分享給他人時,對方仍可進入同一門市的點餐頁。若請求帶有 entry_target,且為合法的站內相對路徑,也會一併轉傳。
- 短碼是公開的入口識別,不是會員憑證;轉址不會附加任何使用者身分資料。
- 原始網址中已存在的
entry_code、entry_target會被移除,以伺服器附加的值為準。
Resource
GET /s/{code}
Authorization
此 API 為公開端點,無需授權。
Path Parameters
| Name | Type | Description |
|---|---|---|
| code | string | 短碼 |
Query Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| entry_target | string | No | 前端要開啟的站內目標頁面(含 query/hash),例如 /menu?source=fb。須以單一 / 開頭,不得含反斜線、空白或控制字元,長度上限 4096;不符合時會被忽略,仍正常轉址 |
Response
HTTP-Status-Code: 302
轉址至原始網址,並附加 entry_code(以及合法的 entry_target,以 URL 編碼)。
HTTP/1.1 302 Found
Location: https://example.com/entry?data=eyJhdXRoa2V5IjogIjdrYW14...&entry_code=AbC12xZ
帶 entry_target 時:
GET /s/AbC12xZ?entry_target=/menu%3Fsource%3Dfb
HTTP/1.1 302 Found
Location: https://example.com/entry?data=eyJhdXRoa2V5IjogIjdrYW14...&entry_code=AbC12xZ&entry_target=%2Fmenu%3Fsource%3Dfb
HTTP-Status-Code: 404
短碼不存在或已失效(是否帶 entry_target 皆相同)。
連結不存在或已失效