v7.1.0
npm i [email protected]
- 🌟 feat: Added new way to configure proxy manually. 3f30dd3 @jaywcjlove
- 💄 chore: update .github/workflows/ci.yml 6ec372f @jaywcjlove
- 💄 chore: update .github/workflows/ci.yml c694325 @jaywcjlove
- 💄 chore(deps): update dependency lint-staged to v12.3.3 (#344) fef83a0 @renovate-bot
- 📖 doc: Update README.md 1ddc815 @jaywcjlove
New Features
import express from 'express';
import { WebpackConfiguration, MockerAPIOptions } from 'kkt';
export default (conf: WebpackConfiguration, evn: 'development' | 'production') => {
//....
+ conf.proxySetup = (app: express.Application): MockerAPIOptions => {
+ return {
+ path: path.resolve('./mocker/index.js'),
+ };
+ };
return conf;
}
Or:
Or use another way to manually configure the proxy.
import express from 'express';
import { createProxyMiddleware } from 'http-proxy-middleware';
import { MockerAPIOptions } from 'kkt';
/**
* Still available, may be removed in the future. (仍然可用,将来可能会被删除。)
*/
export const proxySetup = (app: express.Application): MockerAPIOptions => {
app.use('/api', createProxyMiddleware({
target: 'http://localhost:5000',
changeOrigin: true,
}));
/**
* Mocker API Options
* https://www.npmjs.com/package/mocker-api
*/
return {
path: path.resolve('./mocker/index.js'),
option: {
proxy: {
'/repos/(.*)': 'https://api.github.com/',
},
changeHost: true,
}
}
}