@waline/vercel 1.28.0-alpha.1 → 1.28.0-alpha.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
package/src/config/extend.js
CHANGED
|
@@ -2,6 +2,8 @@ const fetch = require('node-fetch');
|
|
|
2
2
|
const Model = require('think-model');
|
|
3
3
|
const Mongo = require('think-mongo');
|
|
4
4
|
|
|
5
|
+
const { isNetlify, netlifyFunctionPrefix } = require('./netlify');
|
|
6
|
+
|
|
5
7
|
module.exports = [
|
|
6
8
|
Model(think.app),
|
|
7
9
|
Mongo(think.app),
|
|
@@ -16,6 +18,10 @@ module.exports = [
|
|
|
16
18
|
|
|
17
19
|
const { protocol, host } = this;
|
|
18
20
|
|
|
21
|
+
if (isNetlify) {
|
|
22
|
+
return `${protocol}://${host}${netlifyFunctionPrefix}`;
|
|
23
|
+
}
|
|
24
|
+
|
|
19
25
|
return `${protocol}://${host}`;
|
|
20
26
|
},
|
|
21
27
|
async webhook(type, data) {
|
package/src/config/middleware.js
CHANGED
|
@@ -1,16 +1,13 @@
|
|
|
1
1
|
const cors = require('@koa/cors');
|
|
2
2
|
const routerREST = require('think-router-rest');
|
|
3
3
|
|
|
4
|
+
const { isNetlify, netlifyFunctionPrefix } = require('./netlify');
|
|
5
|
+
|
|
4
6
|
const isDev = think.env === 'development';
|
|
5
7
|
const isTcb = think.env === 'cloudbase';
|
|
6
8
|
const isDeta = think.env === 'deta' || process.env.DETA_RUNTIME === 'true';
|
|
7
9
|
const isAliyunFC =
|
|
8
10
|
think.env === 'aliyun-fc' || Boolean(process.env.FC_RUNTIME_VERSION);
|
|
9
|
-
const isNetlify = process.env.NETLIFY_IMAGES_CDN_DOMAIN && process.env._HANDLER;
|
|
10
|
-
const netlifyFunctionPrefix = `/.netlify/functions/${process.env._HANDLER.replace(
|
|
11
|
-
/\.handler$/,
|
|
12
|
-
''
|
|
13
|
-
)}`;
|
|
14
11
|
|
|
15
12
|
module.exports = [
|
|
16
13
|
{
|
|
@@ -67,7 +64,7 @@ module.exports = [
|
|
|
67
64
|
{
|
|
68
65
|
handle: 'router',
|
|
69
66
|
options: {
|
|
70
|
-
prefix: ['/api',
|
|
67
|
+
prefix: ['/api', `${netlifyFunctionPrefix}/api`, netlifyFunctionPrefix],
|
|
71
68
|
},
|
|
72
69
|
},
|
|
73
70
|
|