mocker-api
Advanced tools
Comparing version 1.7.6 to 1.7.7
@@ -32,3 +32,3 @@ #!/usr/bin/env node | ||
res.header('Access-Control-Allow-Origin', '*'); | ||
res.header('Access-Control-Allow-Headers', 'X-Requested-With'); | ||
res.header('Access-Control-Allow-Headers', 'Content-Type,Content-Length,Authorization,Accept,X-Requested-With'); | ||
res.header('Access-Control-Allow-Methods', 'PUT,POST,GET,DELETE,OPTIONS'); | ||
@@ -35,0 +35,0 @@ next(); |
{ | ||
"name": "mocker-api", | ||
"version": "1.7.6", | ||
"version": "1.7.7", | ||
"description": "This is dev support mock RESTful API.", | ||
@@ -11,3 +11,3 @@ "bin": { | ||
"type": "git", | ||
"url": "git+https://github.com/jaywcjlove/webpack-api-mocker.git" | ||
"url": "git+https://github.com/jaywcjlove/mocker-api.git" | ||
}, | ||
@@ -14,0 +14,0 @@ "scripts": { |
@@ -145,3 +145,3 @@ mocker-api | ||
## Delayed Responsev | ||
## Delayed Response | ||
@@ -307,4 +307,8 @@ You can use functional tool to enhance mock. [#17](https://github.com/jaywcjlove/webpack-api-mocker/issues/17) | ||
### Changelog | ||
#### 1.7.7 | ||
* fix issue https://github.com/jaywcjlove/mocker-api/issues/34 | ||
### License | ||
MIT © Kenny Wong | ||
MIT © Kenny Wong |
@@ -85,3 +85,3 @@ const bodyParser = require('body-parser'); | ||
/** | ||
* Get Mocker key | ||
* Get Mocker key | ||
* => `GET /api/:owner/:repo/raw/:ref` | ||
@@ -94,2 +94,11 @@ * => `GET /api/:owner/:repo/raw/:ref/(.*)` | ||
// fix issue 34 https://github.com/jaywcjlove/mocker-api/issues/34 | ||
// In some cross-origin http request, the browser will send the preflighted options request before sending the request methods written in the code. | ||
if (!mockerKey && req.method.toLocaleUpperCase() === 'OPTIONS' | ||
&& Object.keys(mocker).find((kname) => !!pathToRegexp(kname.replace((new RegExp('^(PUT|POST|GET|DELETE) ')), '')).exec(req.path)) | ||
) { | ||
return res.sendStatus(200); | ||
} | ||
if (mocker[mockerKey]) { | ||
@@ -146,3 +155,3 @@ res.setHeader('Access-Control-Allow-Origin', '*'); | ||
function cleanCache(modulePath) { | ||
// The entry file does not have a .js suffix, | ||
// The entry file does not have a .js suffix, | ||
// causing the module's resources not to be released. | ||
@@ -149,0 +158,0 @@ // https://github.com/jaywcjlove/webpack-api-mocker/issues/30 |
20342
250
313