fix: serverless adapter binary body support, hide phone number in register
- Keep body as Buffer instead of utf8 string for multipart/form-data - Set content-length header for multer compatibility - Phone authorization shows '已授权' instead of actual number
这个提交包含在:
@@ -57,7 +57,7 @@ Page({
|
|||||||
http.post('/api/v1/user/phone', { code: e.detail.code }).then(function (data) {
|
http.post('/api/v1/user/phone', { code: e.detail.code }).then(function (data) {
|
||||||
self.setData({
|
self.setData({
|
||||||
loading: false,
|
loading: false,
|
||||||
phone: data.phone || data.pure_phone_number || '已授权'
|
phone: '已授权'
|
||||||
})
|
})
|
||||||
wx.showToast({ title: '手机号授权成功', icon: 'success' })
|
wx.showToast({ title: '手机号授权成功', icon: 'success' })
|
||||||
}).catch(function (err) {
|
}).catch(function (err) {
|
||||||
|
|||||||
@@ -10,7 +10,11 @@ module.exports = function serverless(app) {
|
|||||||
const url = path + (qsStr ? '?' + qsStr : '')
|
const url = path + (qsStr ? '?' + qsStr : '')
|
||||||
|
|
||||||
let rawBody = event.body || ''
|
let rawBody = event.body || ''
|
||||||
if (event.isBase64Encoded && rawBody) rawBody = Buffer.from(rawBody, 'base64').toString('utf8')
|
if (event.isBase64Encoded && rawBody) {
|
||||||
|
rawBody = Buffer.from(rawBody, 'base64')
|
||||||
|
} else if (typeof rawBody === 'string') {
|
||||||
|
rawBody = Buffer.from(rawBody, 'utf8')
|
||||||
|
}
|
||||||
|
|
||||||
return new Promise((resolve) => {
|
return new Promise((resolve) => {
|
||||||
const req = new http.IncomingMessage()
|
const req = new http.IncomingMessage()
|
||||||
@@ -21,6 +25,9 @@ module.exports = function serverless(app) {
|
|||||||
if (event.requestContext && event.requestContext.sourceIp) {
|
if (event.requestContext && event.requestContext.sourceIp) {
|
||||||
req.headers['x-forwarded-for'] = req.headers['x-forwarded-for'] || event.requestContext.sourceIp
|
req.headers['x-forwarded-for'] = req.headers['x-forwarded-for'] || event.requestContext.sourceIp
|
||||||
}
|
}
|
||||||
|
if (rawBody.length > 0) {
|
||||||
|
req.headers['content-length'] = String(rawBody.length)
|
||||||
|
}
|
||||||
|
|
||||||
const res = new http.ServerResponse(req)
|
const res = new http.ServerResponse(req)
|
||||||
let body = ''
|
let body = ''
|
||||||
@@ -52,7 +59,7 @@ module.exports = function serverless(app) {
|
|||||||
|
|
||||||
res.write = function (chunk) { body += chunk }
|
res.write = function (chunk) { body += chunk }
|
||||||
|
|
||||||
if (rawBody) {
|
if (rawBody.length > 0) {
|
||||||
req.push(rawBody)
|
req.push(rawBody)
|
||||||
}
|
}
|
||||||
req.push(null)
|
req.push(null)
|
||||||
|
|||||||
在新工单中引用
屏蔽一个用户