修复小程序后台路由误判
This commit is contained in:
@@ -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))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user