Skip to content

Commit

Permalink
fix: e2e test cases and dead links (#5632)
Browse files Browse the repository at this point in the history
  • Loading branch information
yimingjfe authored Apr 11, 2024
1 parent e8c8c5d commit 0b20bfb
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 48 deletions.
5 changes: 3 additions & 2 deletions packages/cli/uni-builder/src/shared/devServer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ import {
import type { ModernDevServerOptions } from '@modern-js/server';
import type { Server } from 'node:http';
import {
InitProdMiddlewares,
initProdMiddlewares,
type InitProdMiddlewares,
type ProdServerOptions as ModernServerOptions,
} from '@modern-js/prod-server';
import type {
Expand Down Expand Up @@ -157,7 +158,7 @@ export async function startDevServer(
debug('create dev server');

if (!options.initProdMiddlewares) {
throw new Error('Must pass function: initProdMiddlewares');
options.initProdMiddlewares = initProdMiddlewares;
}

const { createDevServer } = await import('@modern-js/server');
Expand Down
22 changes: 0 additions & 22 deletions packages/document/main-doc/docs/en/guides/basic-features/proxy.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -36,25 +36,3 @@ For more detail, see [http-proxy-middleware](https://github.com/chimurai/http-pr
import GlobalProxy from "@site-docs-en/components/global-proxy"

<GlobalProxy />

## BFF Proxy

By configuring [`bff.proxy`](/configure/app/bff/proxy), BFF API requests can be proxied to a specified service. Unlike the other proxy methods above, it can be used in the production environment:

```ts title="modern.config.ts"
export default defineConfig({
bff: {
proxy: {
'/api/v1': 'https://cnodejs.org',
},
},
});
```

For example, when using BFF function in the code, the final request `http://localhost:8080/api/v1/topics` will be automatically proxied to `https://cnodejs.org/api/v1/topics`:

```js
import getTopics from '@api/v1/topics';

getTopics();
```
22 changes: 0 additions & 22 deletions packages/document/main-doc/docs/zh/guides/basic-features/proxy.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -37,25 +37,3 @@ export default defineConfig({
import GlobalProxy from "@site-docs/components/global-proxy"

<GlobalProxy />

## BFF 代理

通过配置 [`bff.proxy`](/configure/app/bff/proxy) 可以代理 BFF API 请求到指定的服务上,上述两种代理不同,它同样可以用在生产环境:

```ts title="modern.config.ts"
export default defineConfig({
bff: {
proxy: {
'/api/v1': 'https://cnodejs.org',
},
},
});
```

例如代码中使用一体化 BFF 调用时,最终请求 `http://localhost:8080/api/v1/topics` 会自动代理到 `https://cnodejs.org/api/v1/topics`

```js
import getTopics from '@api/v1/topics';

getTopics();
```
6 changes: 5 additions & 1 deletion packages/server/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,11 @@
},
"./base/node": {
"types": "./dist/types/base/adapters/node/index.d.ts",
"import": "./dist/esm/base/adapters/node/index.js",
"jsnext:source": "./src/base/adapters/node/index.ts",
"node": {
"require": "./dist/cjs/base/adapters/node/index.js",
"import": "./dist/esm/base/adapters/node/index.js"
},
"default": "./dist/cjs/base/adapters/node/index.js"
}
},
Expand Down
6 changes: 5 additions & 1 deletion tests/e2e/builder/cases/dev/history-api-fallback.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { join } from 'path';
import path, { join } from 'path';
import { expect, test } from '@modern-js/e2e/playwright';
import { dev } from '@scripts/shared';
import { fse } from '@rsbuild/shared';

const cwd = join(__dirname, 'history-api-fallback');

Expand All @@ -10,6 +11,9 @@ test('should provide history api fallback correctly', async ({ page }) => {
entry: {
main: join(cwd, 'src/index.tsx'),
},
serverOptions: {
routes: (await fse.readJSON(path.join(cwd, 'dist', 'route.json'))).routes,
},
builderConfig: {
tools: {
devServer: {
Expand Down

0 comments on commit 0b20bfb

Please sign in to comment.