How to run ReactJs project on server without having port - javascript

Firstly, I'm sorry for my English grammar...
Okay, so I already run my react on the website, but when I type the site URL in the address bar, I need to even put :3000 after the URL. If it's running on-site, I don't want to put the port on the URL.
Can anyone help me on how to run react without the port number in the deployed site?
it should look like this... example.site.com not like example.site.com:3000
If you need any details to tell me in the comments. THANKS IN ADVANCE!!!

Did you run npm run build and take the "build" folder that is generated and copied that folder to your server?
If you did it, its not a React problem/configuration, it's an server configuration, and depends of the server your are using. Nginx is a popular one.
If you don't run npm run build and you put all your project code on the server, and you are running that code with npm start then you are doing it your deployment in the wrong way.

Related

Nuxt.js: How to debug server side after nuxt build (logging some information)

I am using nuxt.js for my frontend app. I currently have a problem with asyncData especially the first time it is run (which is on the server).
When building my app ($ nuxt build and serving it via $ serve), I currently have no real possibility to console.log some information out from the code that is run on the server. How can I debug that part, before code is run on my client?
Would this be a way:
https://codeburst.io/debugging-nuxt-js-with-visual-studio-code-724920140b8f
So I would launch nuxt manually with node.js and try to inspect something there?
Or is there a better way?
The nuxt build properties (https://github.com/webpack-contrib/webpack-bundle-analyzer#options-for-plugin) are just for analyzing the build right? Like package sizes etc, and not for actual code that is run on the server?
I hope I could make clear what I am looking for, if not I am happy to answer further questions.
Any hints are very welcome. Thank you in advance.
cheers

Where should I put the frontend server code in app created with create-react-app?

I created an app with create-react-app and I'd like to log something in its server console. How could I do this?
I've tried adding index.js to the root folder and creating server folder, but it doesn't work.
Edit: I don't mean the backend server here, but just the frontend server. I'd like to print something in the same console where I type npm start. Is it possible?
If I understand correctly to do such a thing you should do eject your create-react-app otherwise you won't be able to modify the build scripts.
After the eject you can modify the webpack script or any other script you need to.
If you decide to do it, be careful because it will be more difficult to update your build dependencies.
First, you cannot put your backend code in the frontend code. Because the backend code is run by Node.JS enabled server. But the front end code is run by your browser.
All the react code will be bundled into one js file, which will be loaded by the browser. It will be simple JS files that renders views.
When you see localhost:3000 the server is given to you by default to VIEW and LOAD your front-end code. Most of the times it is webpack-dev-server.
The common options are:
1) If backend is REST/SOAP api then use XHR/ajax to hit the api. You just have to put the react generated JS file to your backend server's public folder. Also you can use completely different repos/codebases too in this approach.
2) You can use Server side rendering of sort where you put front end code in your backend views.

Why do i need to restart npm server everytime?

I am using VSCode for Reactjs and in the starting when i was learning reactjs, there was no need to restart the server but now after every modification, I have to restart the server and then only the changes are applied on the server
you were probably using nodemon or pm2 or similar tool to watch for file content during development.
on production, that feature is probably not used.
to verify this, looks for scripts section in the package.json file and see what command did you use to develop locally and run on production

Any way to generate documentation of a website project in a restricted environment?

Following the title, I have am unable to execute cmdlets, exe, shellscripts, vb. All that I am able open is git bash, but again, I have no admin rights. Are there any ways of accomplishing this? 1 idea i had was to create a local website that does this for us in the form where we upload a zip file to the website then it does its stuff then repacks it and sends it back to us via a local zip file download?
EDIT:
I am trying to document out a front end site coded in react. Only thing that is able to run anything within itself is Git Bash. No execution of .exe's or cmdlets withing Git Bash works though...
Well, apparently if u have git bash in ur restricted laptop and have the ability to push ur commit to git hub, it seems that using EDoc node module does the job.
Instead of saving globally (which won't work) do a npm install -save esdoc.
Then instead of running esdoc -c [json file], use ./node_modules/esdoc/out/src/esdoccli.js -c [json file]
Worked beautifully for me. Hope this helps anyone who faces a similar situation as me. Feel free to add additional methods to generate documentation.

Unexpected mongo exit code 100 with Meteor

I am trying to follow this answer:
https://stackoverflow.com/a/15752736/4167140
But the path /usr/local/meteor does not exist on my OSX. I ran a single Meteor app on my machine for months and it worked fine, but now that I have multiple meteor apps on my mount, I keep on getting...
Unexpected mongo exit code 100. Restarting.
...when I go to run any of the apps locally (aside from the first one I created).
Did I install Meteor incorrectly? I curl'd it down and I have the executable in /usr/local/bin/meteor, but I need to be able to access /usr/local/meteor in order to get verbose logging when I run mongod inside of the directory.
This happens even on Meteor applications that dont have any collections (just static content).
I have never run into this issue with any of the Meteor + MongoDB applications that I run on my Ubuntu boxes.
Before of to check the installation of Meteor, you could see in your app directory if there is any mongodb.lock, in that case just delete it with rm .meteor/local/db/mongodb.lock (that path is on my linux, maybe it can change a bit, so please check it)
did you try this? There's a bug on github for it...
https://github.com/meteor/meteor/issues/2772
Hey, I don't really have enough to go on for a good answer. But, the .lock file isn't the database. It's a file mongodb writes to prevent itself from starting again on your database. That would get messy. If mongodb crashed, and didn't delete the .lock it wouldn't start again without manual intervention.

Categories