diff --git a/.env.example b/.env.example index b83b7c6..6f36dfc 100644 --- a/.env.example +++ b/.env.example @@ -1,4 +1,6 @@ #Environment ENV= #Default production #App Port -PORT= #Default 80 \ No newline at end of file +PORT= #Default 80 +#Host +HOST= #Default localhost \ No newline at end of file diff --git a/README.md b/README.md index 44b5d90..e376ee1 100644 --- a/README.md +++ b/README.md @@ -29,6 +29,8 @@ This is an exaple of config. ENV= #Default production #App Port PORT= #Default 80 +#Host +HOST= #Default localhost ``` The default environment is production and the app port defauld is 80. diff --git a/bin/cli.js b/bin/cli.js index 36caaef..29b5974 100644 --- a/bin/cli.js +++ b/bin/cli.js @@ -102,7 +102,7 @@ if(!cleanGitHistory) process.exit(-1); console.log('Congratulations! You are ready. Follow the following commands to start'); console.log(`cd ${repoName}`); -console.log('Create a .env file with ENV=development(defauld: production), PORT=3000 (default: 80)'); +console.log('Create a .env file with ENV=development(default: production), PORT=3000 (default: 80), HOST=domain.com (default: localhost)'); console.log('Then you can run: npm start-frontend:dev'); console.log('Then you can run: npm start-server:dev'); diff --git a/config/index.ts b/config/index.ts index b36bb24..c60c985 100644 --- a/config/index.ts +++ b/config/index.ts @@ -4,6 +4,7 @@ export const deFaultValues = { PUBLIC_URL: 'auto', PREFIX_URL: '', ONLY_EXACT_PATH: false, + HOST: 'localhost', }; export const config = { @@ -12,6 +13,7 @@ export const config = { PUBLIC_URL: process.env.PUBLIC_URL ? process.env.PUBLIC_URL : deFaultValues.PUBLIC_URL, PREFIX_URL: process.env.PREFIX_URL ? process.env.PREFIX_URL : deFaultValues.PREFIX_URL, ONLY_EXACT_PATH: process.env.ONLY_EXACT_PATH ? process.env.ONLY_EXACT_PATH === 'true' : deFaultValues.ONLY_EXACT_PATH, + HOST: process.env.HOST ? process.env.HOST : deFaultValues.HOST, }; export default config; diff --git a/package.json b/package.json index 4215985..716f542 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@aleleba/create-react-go-ssr", - "version": "1.0.0", + "version": "1.0.1", "description": "Starter Kit of server side render of react with backend in go", "bin": "./bin/cli.js", "scripts": { diff --git a/src/frontend/components/App.tsx b/src/frontend/components/App.tsx index 26764a6..04ae6ec 100644 --- a/src/frontend/components/App.tsx +++ b/src/frontend/components/App.tsx @@ -5,7 +5,7 @@ import { config } from '../../../config'; const App = () => { if(config.ENV === 'development') { useEffect(() => { - const ws = new WebSocket('wss://nmr4jbx8-3000.use.devtunnels.ms/ws'); + const ws = new WebSocket(`wss://${config.HOST}/ws`); ws.onmessage = (event) => { if (event.data === 'reload') { window.location.reload();