Skip to content

Commit

Permalink
feat: Enable Express Port Changes (QwikDev#1478)
Browse files Browse the repository at this point in the history
* Enable Express Port Changes

When deploying qwik with express for SSR to a service such as cloud run (or something else) a team should be able to control what port the application is served from. This change should be a good place to start, however there could be a better way to do this and I'm open to that feedback from the qwik core team. This was just a quick thought on how I could solve the problem that I was facing with my deployment.

* Update to show correct PORT

* Fix Prettier Errors
  • Loading branch information
hkd987 authored Sep 26, 2022
1 parent 3294cb9 commit 1a92f60
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
7 changes: 4 additions & 3 deletions packages/qwik-city/runtime/src/entry.express.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ const buildDir = join(distDir, 'build');

// Create the Qwik City express middleware
const { router, notFound } = qwikCity(render);

// Allow for dynamic port
const PORT = process.env.PORT ?? 3000;
// Create the express server
const app = express();

Expand All @@ -25,7 +26,7 @@ app.use(router);
app.use(notFound);

// Start the express server
app.listen(3000, () => {
app.listen(PORT, () => {
/* eslint-disable */
console.log(`http://localhost:3000/`);
console.log(`http://localhost:${PORT}/`);
});
7 changes: 4 additions & 3 deletions starters/servers/express/src/entry.express.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ const buildDir = join(distDir, 'build');

// Create the Qwik City express middleware
const { router, notFound } = qwikCity(render);

// Allow for dynamic port
const PORT = process.env.PORT ?? 3000;
// Create the express server
// https://expressjs.com/
const app = express();
Expand All @@ -27,7 +28,7 @@ app.use(router);
app.use(notFound);

// Start the express server
app.listen(3000, () => {
app.listen(PORT, () => {
/* eslint-disable */
console.log(`http://localhost:3000/`);
console.log(`http://localhost:${PORT}/`);
});

0 comments on commit 1a92f60

Please sign in to comment.