CSS isn't loading after deploying NextJS app to Cpanel - reactjs

I have deployed my NextJS app to Cpanel, but CSS isn't working anymore + the router isn't working so no routing.
Can you guys help me with how this problem can be resolved?
Project Structure:
Server.js
App.js (I selected App.js while creating Node.Js application in Cpannel)
Final result I am getting :

Related

React app not rendering whole app and only showing "edit app.js".What can I do?

My react is running fine on local host, but when I upload it online for ex : Heroku, Vercel, It only shows the react home screen "edit app.js". The app is not working.
It might be because your index.html file being hosted still has the boiler plate code. Based on how you're deploying your app, a html is usually created for you with some boiler plate (I know firebase does this for example).

React Router / Wordpress htaccess Issue

I'm building a React plugin in Wordpress (for my own purposes).
I've used 'create-react-app', then 'yarn build' and then upload the production 'build' folder into Wordpress to a custom directory '/apps/my-custom-app/frontend/build'.
I've used this tutorial to create a Wordpress plugin that gets all the assets from the 'build' folder and renders the React App in the target div on a Wordpress page.
All of this works as expected, the React App renders on my Wordpress page "https://mywebsite.com/wp-page-slug/" and the React routing/navigation works fine ... but only within the React App.
The issue is that if I'm on a React page (except for the root slug) and refresh the browser, I end up getting a 404 error.
After researching on StackOverflow, I've found that this is resolved using the .htaccess file.
I've used this function from the solution in this article ...
add_action( 'init', 'my_custom_app_frontent_rewrite_rule' );
function my_custom_app_frontent_rewrite_rule() {
add_rewrite_rule('^react-app-root-url/(.+)?', 'index.php?pagename=wp-page-slug', 'top');
}
... to add a rewrite rule, but there's something wrong. When I enable it, the entire frontend of the website goes blank (white screen).
Is the 'add_rewrite_rule' not correct? I don't know what's wrong here.
Wordpress Permalinks are currently set to 'Post Name'.
The Wordpress page slug is '/wp-page-slug'.
The React App Router Base URL is '/react-app-root-url'.
And the homepage property in the React package.json file is '/apps/my-custom-app/frontend/build'.
Any assistance would be appreciated, thank you.

My greeting, Some problems with react routing when project hosted

I created react dom routing in my react app. Component navigation works if you run npm start, but if the project is built and hosted, a 404 error occurs during navigation This happens because the hosting requests index.html when the react changes the main html file to (page name) .html during navigation.

How to deploy a react application on a static server

I have a react application build with create-react-app. Its using octoberCMS as the backend fetching data using Axios calls from the frontend. Till now I was developing keeping the build content of react inside a directory named 'react' in the root directory of octoberCMS installation. Hence the URL I was hitting was http://example.com/react/.
The problem is now I am done with the development phase and look forward to deployment. But I want my front-end to be served at http://example.com and backend to be served at http://example.com/backend (backend served as I want). How can I achieve this? I am fairly new to both frameworks.
I have tried keeping the build content along with the rest of the octoberCMS
First build your react app that will give you vendor.js[third party scripts] and your app.js[your actual app]
put them in to theme directory assets something
Then In Ocotber CMS make page with URL /:url? and paste your index.html content there.
it will be your root div and including js html, change path for js which points to the build js which you put in theme directory.
now what happens when anybody come to site
- we are serving same content as we do in dev build
- index.html with root tag and needed js
Now if use hit any other url like https://www.example.com/test/etc it also will be catch by /:url? (and all other requests) and home page served and our react app will work as we needed.
if any questions please comment.

Offline static content in React app

I have a react app created with create-react-app. I would like to add an image not part of the react app to the offline manifest. The image is just referenced from index.html. I don't understand how I can include this in the offline manifest.
The react app is ejected.
Put the image in the public folder just as in a regular website and refer to that image. Everything in the src folder is put in a big js file after building so you cant use that

Resources