change routee

This commit is contained in:
2026-08-04 18:01:20 +05:00
parent 2dc0d1faa6
commit bd7bdf5867
16 changed files with 47 additions and 41 deletions

View File

@@ -4,7 +4,7 @@
* - Sends the raw JWT access token in the Authorization header
* (the backend middleware expects the bare token, no "Bearer " prefix).
* - Unwraps the response envelope { status, message, code, data }.
* - On 401 tries a one-shot refresh via POST /v1/admin/token, then retries.
* - On 401 tries a one-shot refresh via POST /api/v1/admin/token, then retries.
* - Throws ApiError with a friendly, human-readable message.
*/
(function () {
@@ -95,7 +95,7 @@
const refreshToken = tokens.refresh;
if (!refreshToken) return false;
try {
const response = await fetch("/v1/admin/token", {
const response = await fetch("/api/v1/admin/token", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ refreshToken }),
@@ -116,7 +116,7 @@
/**
* Perform an authenticated JSON request.
* @param {string} method HTTP method
* @param {string} path request path, e.g. /v1/admin/news
* @param {string} path request path, e.g. /api/v1/admin/news
* @param {{ body?: object, query?: object, formData?: FormData, retried?: boolean }} [options]
*/
async function request(method, path, options) {
@@ -171,7 +171,7 @@
function upload(file) {
const formData = new FormData();
formData.append("file", file);
return request("POST", "/v1/admin/file", { formData });
return request("POST", "/api/v1/admin/file", { formData });
}
window.Api = {