eggjs / eggjs/egg

egg-cors本地开发体验增强-不需要设置端口

Open
#2,192 3 comments 0 reactions 1 assignee Claimed by @jtyjty99999 View on GitHub
Inactive
Dominant language
TypeScript
Stars
19k
Forks
1.8k
PR merge metrics
No merged PRs in 30d

Description

如果线上的safedomain 是 xxx.xx.com 本地开发的时候一般是 xxx.xx.com:7001, 这样会需要在domainwhitelist里面配一个带端口的地址。

我们本地开发的时候,是不是可以默认做端口忽略? 比如

```
cors: {origin: function judgeWithoutPort(ctx) {
const origin = ctx.get('Origin');
const hostname = url.parse(origin).hostname;
if (ctx.isSafeDomain(hostname)) {
return origin;
}
return '';
}
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.