-
Notifications
You must be signed in to change notification settings - Fork 3
feat(host): flag to use req.host instead of localhost #14
Conversation
Do we need to mention something in the Readme? |
@@ -57,6 +57,7 @@ export default ({ | |||
remoteModuleMapUrl, | |||
useLocalModules, | |||
appPort, | |||
useHost, | |||
}) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what about adding something like below here. you can probably come up with a better name however
}) => { | |
}) => { | |
const hostAddress = useHost ? `http://${req.headers.host}` : `http://localhost:${process.env.HTTP_ONE_APP_DEV_CDN_PORT}`; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
had to put it inside the get
for the req
to be accessible but Implemented your changes here: 1c5a17c
src/index.js
Outdated
@@ -106,7 +107,7 @@ export default ({ | |||
const remoteModuleMap = JSON.parse(r.body); | |||
|
|||
const { modules } = remoteModuleMap; | |||
const oneAppDevStaticsAddress = `http://localhost:${process.env.HTTP_ONE_APP_DEV_CDN_PORT}/static`; | |||
const oneAppDevStaticsAddress = useHost ? `http://${req.headers.host}/static` : `http://localhost:${process.env.HTTP_ONE_APP_DEV_CDN_PORT}/static`; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
continued from comment above -
const oneAppDevStaticsAddress = useHost ? `http://${req.headers.host}/static` : `http://localhost:${process.env.HTTP_ONE_APP_DEV_CDN_PORT}/static`; | |
const oneAppDevStaticsAddress = `${hostAddress}/static`; |
this change can also be applied below
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
src/index.js
Outdated
@@ -141,7 +142,7 @@ export default ({ | |||
: {}, | |||
(useLocalModules ? getLocalModuleMap({ | |||
pathToModulemap: path.join(localDevPublicPath, 'module-map.json'), | |||
oneAppDevCdnAddress: `http://localhost:${process.env.HTTP_ONE_APP_DEV_CDN_PORT}`, | |||
oneAppDevCdnAddress: useHost ? `http://${req.headers.host}}` : `http://localhost:${process.env.HTTP_ONE_APP_DEV_CDN_PORT}`, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oneAppDevCdnAddress: useHost ? `http://${req.headers.host}}` : `http://localhost:${process.env.HTTP_ONE_APP_DEV_CDN_PORT}`, | |
oneAppDevCdnAddress: hostAddress, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added documentation to README 1c5a17c |
@@ -84,13 +84,23 @@ location where the remote module map is located (i.e. `https://my-domain.com/map | |||
|
|||
Type: `boolean` | |||
|
|||
Default: `true`<br> | |||
Whether to use modules from `localDevPublicPath`. Passed as `true` or `false`, defaults to `true`. | |||
Default: `false`<br> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the code this never defaulted to true so I updated the README to reflect
# [3.3.0](v3.2.2...v3.3.0) (2020-05-13) ### Features * **host:** flag to use req.host instead of localhost ([#14](#14)) ([5e761a7](5e761a7))
🎉 This PR is included in version 3.3.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
In order for the browser tests to run the dev-cdn the module map has to point to the host instead of localhost. I have added the flag
useHost
to be set to true when running browser tests and false as default when using one-app-runner so it points to localhost during local development.Tested by passing the flag from one-app, building a dev docker image, passing the image local to one-app-runner and running the browser tests. both scenarios worked as expected