Skip to content

Commit

Permalink
fix: 修复 header origin 为空时报错的问题
Browse files Browse the repository at this point in the history
  • Loading branch information
renxia committed Feb 18, 2024
1 parent 1a782ca commit de81306
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 6 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ npm add @lzwme/captcha-cv-ocr
因为所需的 OpenCV 支持模块 [@u4/opencv4nodejs](https://github.com/UrielCh/opencv4nodejs) 体积较大,编译过程复杂,请手动安装,或者参考官方的安装指南:

```bash
npm i @u4/opencv4nodejs -g
npm i @u4/opencv4nodejs
```

### 用法
Expand Down
3 changes: 1 addition & 2 deletions lib/createServer.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ async function createServer({ port, baseDir = process.cwd() } = {}) {

const clientServer = http.createServer(async (req, res) => {
const corsHeaders = {
'Access-Control-Allow-Origin': req.headers.origin,
'Access-Control-Allow-Origin': req.headers.origin || '*',
'Content-Type': 'application/json',
'Access-Control-Allow-Headers': 'Content-Type,Content-Length,Authorization,Accept,X-Requested-With',
};
Expand Down Expand Up @@ -97,4 +97,3 @@ async function createServer({ port, baseDir = process.cwd() } = {}) {
}

exports.createServer = createServer;

4 changes: 1 addition & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,5 @@
"optionalDependencies": {
"@img/sharp-win32-x64": "^0.33.1"
},
"peerDependencies": {
"@u4/opencv4nodejs": ">=6.5.0"
}
"peerDependencies": {}
}

0 comments on commit de81306

Please sign in to comment.