ReactJS problem routing with deployment using apache2 - reactjs

I have been searching the web for solutions for my setup and no luck.
Note: All of these links work properly (www.mywebsite.com and www.mywebsite.com/subPage) when I run the app locally. When I deploy the app, the www.mywebsite.com works, but www.mywebsite.com/subPage does not work (404 NOT FOUND)
I have a website www.mywebsite.com that routes to xxx.xxx.xxx.xxx:80/mywebsite (This is on goDaddy)
This directory on my server that has the static files from the reactJS build is: /var/www/html/mywebsite
So basically the www.mywebsite.com -> /var/www/html/mywebsite
I am fairly certain I have a problem with my .htaccess (which is blank). I have tried many things from online, many different .htaccess files, but nothing I looked at covers my exact configuration.
I have tried putting the .htaccess file in /var/www/html
I have tried putting the .htaccess file in /var/www/html/mywebsite
I have also tried putting it in both. Nothing worked. My AllowOverride All is set properly and I turned on the rewrite module using instructions online and verified this.

Related

How to support react js app for 2 different sub domains

I am a bit struggle with support to a react js to support 2 different subdomains. Followings are the subdomains I need my app to support
www-dev.somedomain/apps/myapp
app-dev.somedomain/myapp
As you can see, react-app-path is also changing with the subdomains. I have defined PUBLIC_URL and REACT_APP_PATH in my .env file as below.
REACT_APP_PATH=/myapp
GENERATE_SOURCEMAP=false
PUBLIC_URL=/myapp
With above env vars app-dev... URL is working. If I change to the path to apps/myapp then www subdomain in working. I need a way to support both subdomains at once
How can I achieve this?
Finally, I solved this problem with the following steps; I was using Nginx to be redirected to the same host. The problem I have was with the paths.
www-dev.somedomain/apps/myapp
app-dev.somedomain/myapp
According to my Nginx configurations, both URLs were redirected to / in the server. Then the app couldn't find the static files because paths were different with domains. So to fix this, I did as below.
First, remove PUBLIC_URL from my env file. Then app files will be hosted at the / location
Added homepage attribute to package.json file. adding homepage will serve assets relative to index.html. Read more about homepage. Using `"homepage"` in package.json, without messing up paths for localhost
Since the app is using internal routing, I added simple Nginx rule to rewrite the location of static files as below.
rewrite /static/(.*)$ /static/$1 break;
This solved my problem with supporting two doamins.
No way, Your React app will be compiled into static HTML, JS, and CSS files, and the only time you can pass parameters to the build tool is before building, which is what you're doing right now. Once the building is complete, it can't be changed.
You can write two shell script, with different environment variable. Then invoke each of them will build different web app.

angular js path returns 404 error when https is used

Please keep in mind, I have not worked with angular JS, nor did I write the code that is causing the error.
I am getting an 404 error on this path:
https://www.helivalues.com/Su6UsWuf/bb/option/mfg/all
but not this path:
http://www.helivalues.com/Su6UsWuf/bb/option/mfg/all
It was noticed that when a user views a certain page in https, the drop down does not load options. Angular Js makes a call to the path mention above which is not an actually file but is used by a php file that based on this path, has a switch that fills in the drop down.
Any ideas on how to get the https version to work? This is on a joomla site and I do have access to the htaccess file if needed. I really just need it to work for a few months while I work on building a new site.
Thanks!
Angularjs is not the issue. Your webserver (Apache/2.2.15 (SuSE) Server at www.helivalues.com Port 443) states the file can not be found. So it looks like something is misconfigured with your apache site.

Apache and Yeoman built NodeJS app on the Same Server... Virtual Hosts?

I've been trying to add a NodeJS app (built by Yeoman - angular-fullstack generator) on my apache server.
I've found this other answered question : Apache and Node.js on the Same Server
suggesting to use ProxyPass like this :
ProxyPass /node http://localhost:8000/
The problem I encounter when I do that is that my app starts on an index.html wich includes some files with href.
Since these hrefs doesn't start like this
href="/node/..."
They aren't redirected by Proxypass, and thus result in a 404 error.
I can't just change all the hrefs : that would mean I need to do it all over again on my 3 environment : development, production and test, and even if I did that, everytime I'll use Grunt to test my app, it automatically rebuild my index.html anyway. (Besides, it doesn't solve everything, there are some problems with socketio appearing when I do that)
Only thing I can do then is using ProxyPass like this :
ProxyPass / http://localhost:8000/
There it does works, absolutely no problem, just like if I actually was using the app on from my server on localhost.
The only remaining problem is that I need to have 2 environments on my server, on for production and on for tests, and I just can't do
ProxyPass / http://localhost:8000/
ProxyPass / http://localhost:8001/
It obviously won't work since everything will be redirected to port 8000 bvefore anything can reach the second line.
So, I'm left with only two options :
Either find another solution than using "/" as criterion for redirecting to localhost:8000 that would work in the same manner (and I didn't find anything working)
Or use virtual hosts... And there goes another problem : I'm really not confortable with network issues, from what I understood, to have several virtual hosts on the same machine, I need several CNAMES (one for each virtual hosts), but I don't know how to list / add CNAMES (my server runs on Windows Server 2008 with no access to the world wide web), and I don't have any "DNS" application in my "Administrative Tools" as I'm supposed to according to this : https://technet.microsoft.com/en-gb/library/cc753579.aspx
Any help would be very welcome
Thanks in advance !
EDIT : I really think that my solution is to twitch my Apache configuration. Can anyone used to deal with server configs help me? :/
Seems like all I was missing was a
<base href="/node/">
tag (didn't even know about it, and Yeoman created it as )
I still have a problem though :
Socket.io ... I don't really get my own problem here : it's in node_modules (wich is normal since I need it in my server and my client), but trying to include it as I was doing so before using base href fails.
I don't even get how it did work before : (index.html : )
<script src="socket.io-client/socket.io.js"></script>
This doesn't seem right knowing my project folder is like this :
[PROJECT ROOT]
-client
--index.html
-node_modules
--socket.io-client
---socket.io.js

URL rewriting is not properly configured on your server

I tried upgrading my cakephp version from 1.3 to 2.5 but encountered an url rewriting problem. Another cakephp app runs on the same version so I'm sure the mod_rewrite works.
Although when I go to example.com/pages/home I get following error:
URL rewriting is not properly configured on your server. 1) Help me configure it 2) I don't / can't use URL rewriting
When I go to my normal home page and I want to click on a home link I get following url :
http://example.com/app/webroot/index.php/
And it is the same for other urls.
http://example.com/antwerp becomes http://example.com/app/webroot/index.php/antwerp
When I go to http://example.com/antwerp the site works as it should...
Any ideas where I've gone wrong?
I would suggest accessing your account and re-uploading your .htaccess files from and to the following locations respectivelly.
/app
.htaccess
/webroot
.htaccess
.htaccess
Some FTPs do not upload those files automatically until you force it to.
If that does not work, check if you have your php.ini file in your public_html folder of this application.

CakePHP 1.3.0 RC4 Installation

I have been using 1.2.6 and downloaded 1.3 to try it out. I am using wampserver with Apache 2.2.11. I have mod rewrite enabled. When I bake a new application using the cake 1.3 console, after I verify that the webroot/index.php of the application CAKE_CORE_INCLUDE_PATH is set to the Cake1.3 Installation folder. The result is a page thats missing CSS, missing a method. Typing in localhost/app/index.php will enable the program to find the app. Therefore I have to assume the rewrite module isnt functioning properly for v1.3. Is there something I have to add to the cake installation or app folder to make this function as it should?
No, Cake is set up properly from the start. The thing that always trips me up is that I forget to set my Apache virtual host's AllowOverride value to All. This allows the .htaccess file to be read.
Are there any error messages in your apache error logs?
Did you replace the previous application's directory with the new one? If not, you may need to add a tag with the appropriate AllowOverride permissions set inside your httpd.conf file, to allow mod rewrite to execute.
Can you load /css/style.css in your browser or does it give a 404?
This may sound like a silly question, but after you made your changes to AllowOverride in your Apache configuration, did you restart Apache?

Resources