PR-394587: Adding support to custom host.

This commit is contained in:
Alejandro Lembke Barrientos 2023-10-07 04:42:03 +00:00
parent 34236b7738
commit 47314b8e5b
6 changed files with 10 additions and 4 deletions

View File

@ -1,4 +1,6 @@
#Environment
ENV= #Default production
#App Port
PORT= #Default 80
PORT= #Default 80
#Host
HOST= #Default localhost

View File

@ -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.

View File

@ -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');

View File

@ -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;

View File

@ -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": {

View File

@ -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();