Repository navigation
tests(start): update spa mode e2e to use production build #5284
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 5 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
f50425b
make use of prod setup for spa-mode e2e test
nlynzaad 872c411
Merge branch 'main' into e2e-basic-spa
nlynzaad 42b217a
ci: apply automated fixes
autofix-ci[bot] 22bdd74
Merge branch 'main' into e2e-basic-spa
nlynzaad 32500fd
Merge branch 'main' into e2e-basic-spa
nlynzaad 090b0c7
nitpick
nlynzaad File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,67 @@ | ||
| import { toNodeHandler } from 'srvx/node' | ||
| import path from 'node:path' | ||
| import express from 'express' | ||
| import { createProxyMiddleware } from 'http-proxy-middleware' | ||
|
|
||
| const port = process.env.PORT || 3000 | ||
|
|
||
| const startPort = process.env.START_PORT || 3001 | ||
|
|
||
| export async function createStartServer() { | ||
| const server = (await import('./dist/server/server.js')).default | ||
| const nodeHandler = toNodeHandler(server.fetch) | ||
|
|
||
| const app = express() | ||
|
|
||
| app.use(express.static('./dist/client')) | ||
|
|
||
| app.use(async (req, res, next) => { | ||
| try { | ||
| await nodeHandler(req, res) | ||
| } catch (error) { | ||
| next(error) | ||
| } | ||
| }) | ||
|
|
||
| return { app } | ||
| } | ||
|
|
||
| export async function createSpaServer() { | ||
| const app = express() | ||
|
|
||
| app.use( | ||
| '/api', | ||
| createProxyMiddleware({ | ||
| target: `http://localhost:${startPort}/api`, // Replace with your target server's URL | ||
| changeOrigin: false, // Needed for virtual hosted sites, | ||
| }), | ||
| ) | ||
|
nlynzaad marked this conversation as resolved.
Resolved
|
||
|
|
||
| app.use( | ||
| '/_serverFn', | ||
| createProxyMiddleware({ | ||
| target: `http://localhost:${startPort}/_serverFn`, // Replace with your target server's URL | ||
| changeOrigin: false, // Needed for virtual hosted sites, | ||
| }), | ||
| ) | ||
|
|
||
| app.use(express.static('./dist/client')) | ||
|
|
||
| app.get('/{*splat}', (req, res) => { | ||
| res.sendFile(path.resolve('./dist/client/index.html')) | ||
| }) | ||
|
nlynzaad marked this conversation as resolved.
Resolved
|
||
|
|
||
| return { app } | ||
| } | ||
|
|
||
| createSpaServer().then(async ({ app }) => | ||
| app.listen(port, () => { | ||
| console.info(`Client Server: http://localhost:${port}`) | ||
| }), | ||
| ) | ||
|
|
||
| createStartServer().then(async ({ app }) => | ||
| app.listen(startPort, () => { | ||
| console.info(`Start Server: http://localhost:${startPort}`) | ||
| }), | ||
| ) | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,67 @@ | ||
| import { toNodeHandler } from 'srvx/node' | ||
| import path from 'node:path' | ||
| import express from 'express' | ||
| import { createProxyMiddleware } from 'http-proxy-middleware' | ||
|
|
||
| const port = process.env.PORT || 3000 | ||
|
|
||
| const startPort = process.env.START_PORT || 3001 | ||
|
|
||
| export async function createStartServer() { | ||
| const server = (await import('./dist/server/server.js')).default | ||
| const nodeHandler = toNodeHandler(server.fetch) | ||
|
|
||
| const app = express() | ||
|
|
||
| app.use(express.static('./dist/client')) | ||
|
|
||
| app.use(async (req, res, next) => { | ||
| try { | ||
| await nodeHandler(req, res) | ||
| } catch (error) { | ||
| next(error) | ||
| } | ||
| }) | ||
|
|
||
| return { app } | ||
| } | ||
|
|
||
| export async function createSpaServer() { | ||
| const app = express() | ||
|
|
||
| app.use( | ||
| '/api', | ||
| createProxyMiddleware({ | ||
| target: `http://localhost:${startPort}/api`, // Replace with your target server's URL | ||
| changeOrigin: false, // Needed for virtual hosted sites, | ||
| }), | ||
| ) | ||
|
|
||
| app.use( | ||
| '/_serverFn', | ||
| createProxyMiddleware({ | ||
| target: `http://localhost:${startPort}/_serverFn`, // Replace with your target server's URL | ||
| changeOrigin: false, // Needed for virtual hosted sites, | ||
| }), | ||
| ) | ||
|
|
||
| app.use(express.static('./dist/client')) | ||
|
|
||
| app.get('/{*splat}', (req, res) => { | ||
| res.sendFile(path.resolve('./dist/client/index.html')) | ||
| }) | ||
|
nlynzaad marked this conversation as resolved.
Resolved
|
||
|
|
||
| return { app } | ||
| } | ||
|
|
||
| createSpaServer().then(async ({ app }) => | ||
| app.listen(port, () => { | ||
| console.info(`Client Server: http://localhost:${port}`) | ||
| }), | ||
| ) | ||
|
|
||
| createStartServer().then(async ({ app }) => | ||
| app.listen(startPort, () => { | ||
| console.info(`Start Server: http://localhost:${startPort}`) | ||
| }), | ||
| ) | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.