|
@@ -10,7 +10,7 @@ function registerRoutes(app) {
|
|
|
let mockLastIndex
|
|
|
const { mocks } = require('./index.js')
|
|
|
const mocksForServer = mocks.map(route => {
|
|
|
- return responseFake(route.url, route.type, route.response)
|
|
|
+ return responseFake(route.url, route.server, route.type, route.response)
|
|
|
})
|
|
|
for (const mock of mocksForServer) {
|
|
|
app[mock.type](mock.url, mock.response)
|
|
@@ -32,9 +32,14 @@ function unregisterRoutes() {
|
|
|
}
|
|
|
|
|
|
// for mock server
|
|
|
-const responseFake = (url, type, respond) => {
|
|
|
+const responseFake = (url, server, type, respond) => {
|
|
|
+ console.log(server)
|
|
|
+ var url = new RegExp(`${process.env.VUE_APP_BASE_API}${url}`);
|
|
|
+ if(server == 'worker') {
|
|
|
+ url = new RegExp(`${process.env.VUE_APP_WORKER_API}${url}`);
|
|
|
+ }
|
|
|
return {
|
|
|
- url: new RegExp(`${process.env.VUE_APP_BASE_API}${url}`),
|
|
|
+ url: url,
|
|
|
type: type || 'get',
|
|
|
response(req, res) {
|
|
|
console.log('request invoke:' + req.path)
|