修复小程序后台路由误判
This commit is contained in:
@@ -153,7 +153,6 @@ module.exports = {
|
||||
BASE_DOMAIN,
|
||||
BRAND_CONFIG,
|
||||
API_DOMAIN: `${BASE_DOMAIN}/api`,
|
||||
ADMIN_API_BASE_URL: `${BASE_DOMAIN}/api/admin`,
|
||||
REQUEST_TIMEOUT: normalizeRequestTimeout(localOverride.requestTimeout),
|
||||
ENABLE_REQUEST_SIGNING: localOverride.enableRequestSigning !== false
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
const { ADMIN_API_BASE_URL, REQUEST_TIMEOUT, ENABLE_REQUEST_SIGNING } = require('./config')
|
||||
const { API_DOMAIN, REQUEST_TIMEOUT, ENABLE_REQUEST_SIGNING } = require('./config')
|
||||
const auth = require('./auth')
|
||||
const { sha256Hex, hmacSha256Hex, buildCanonicalParams, buildJsonPayload, randomNonce } = require('./crypto')
|
||||
|
||||
@@ -11,7 +11,7 @@ let sessionExpiredHandling = false
|
||||
|
||||
function buildUrl(url, params) {
|
||||
const sourceParams = params || {}
|
||||
const baseUrl = sourceParams.__baseUrl ? sourceParams.__baseUrl : ADMIN_API_BASE_URL
|
||||
const baseUrl = sourceParams.__baseUrl ? sourceParams.__baseUrl : API_DOMAIN
|
||||
const query = Object.keys(sourceParams)
|
||||
.filter(key => key !== '__baseUrl')
|
||||
.filter(key => sourceParams[key] !== undefined && sourceParams[key] !== null && sourceParams[key] !== '')
|
||||
@@ -82,40 +82,26 @@ function extractPath(value) {
|
||||
|
||||
function toBackendRequestPath(url) {
|
||||
const path = extractPath(url).replace(/\/+$/, '') || '/'
|
||||
if (path === '/api/admin') {
|
||||
return '/admin'
|
||||
}
|
||||
if (path.startsWith('/api/admin/')) {
|
||||
return `/admin/${path.slice('/api/admin/'.length)}`
|
||||
}
|
||||
if (path === '/api') {
|
||||
return '/'
|
||||
}
|
||||
if (path.startsWith('/api/')) {
|
||||
return `/${path.slice('/api/'.length)}`
|
||||
}
|
||||
if (path === '/admin/api') {
|
||||
return '/admin'
|
||||
}
|
||||
if (path.startsWith('/admin/api/')) {
|
||||
return `/admin/${path.slice('/admin/api/'.length)}`
|
||||
}
|
||||
if (path === '/admin' || path.startsWith('/admin/')) {
|
||||
return path
|
||||
}
|
||||
return path.startsWith('/') ? `/admin${path}` : `/admin/${path}`
|
||||
return path
|
||||
}
|
||||
|
||||
function isAuthFreePath(url) {
|
||||
return [
|
||||
'/auth/login',
|
||||
'/auth/register',
|
||||
'/user/login',
|
||||
'/user/workbench/register/',
|
||||
'/user/workbench/shops/available',
|
||||
'/user/check/login-shops/',
|
||||
'/user/send-verification-code',
|
||||
'/user/phone-login',
|
||||
'/user/wechat-mini/',
|
||||
'/user/check/login-shops/',
|
||||
'/legal-agreement/current'
|
||||
].some(path => String(url || '').includes(path))
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
const { ADMIN_API_BASE_URL, API_DOMAIN, REQUEST_TIMEOUT } = require('./config')
|
||||
const { API_DOMAIN, REQUEST_TIMEOUT } = require('./config')
|
||||
const request = require('./request')
|
||||
|
||||
function normalizeUploadResponse(response, fallbackMessage) {
|
||||
@@ -32,7 +32,7 @@ function preserveResponseId(rawText, payload) {
|
||||
|
||||
function uploadFile(options) {
|
||||
const method = 'POST'
|
||||
const baseUrl = options.baseUrl || ADMIN_API_BASE_URL
|
||||
const baseUrl = options.baseUrl || API_DOMAIN
|
||||
const url = `${baseUrl}${options.url}`
|
||||
const signatureHeaders = request.buildSignatureHeaders({
|
||||
url: options.url,
|
||||
|
||||
Reference in New Issue
Block a user