500 internal Server Error on Shared hosting

Akinniyi Bode Bolade

I have a react app hosted at www.example.com, while the REST API is a node app inside a backend folder that is linked to www.api.example.com

however, my rest API shows 500 internal server errors anytime I have content in the .htaccess file from my react build. This .htaccess is needed for my react app to render well.

I have tried several options but it seems there is none that works for my use case.

here is my .htaccess file located in the public_html folder of my Cpanel

Options -MultiViews
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteRule ^ index.html [QSA,L]

when I used the below, I started getting cors preflight issue which wasn't

<IfModule mod_rewrite.c>

  RewriteEngine On
  RewriteBase /
  RewriteRule ^index\.html$ - [L]
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteCond %{REQUEST_FILENAME} !-l
  RewriteRule . /index.html [L]

</IfModule>

My log file is showing this

App 5580 output: Warning: unable to write to /var/passenger/passenger.spawn.XXXXb1ACSv/response/steps/subprocess_exec_wrapper/end_time: The "data" argument must be of type string or an instance of Buffer, TypedArray, or DataView. Received type number (1617603108.1)
App 5580 output: Warning: unable to write to /var/passenger/passenger.spawn.XXXXb1ACSv/response/steps/subprocess_wrapper_preparation/begin_time: The "data" argument must be of type string or an instance of Buffer, TypedArray, or DataView. Received type number (1617603108.104)
App 5580 output: Warning: unable to write to /var/passenger/passenger.spawn.XXXXb1ACSv/response/steps/subprocess_wrapper_preparation/begin_time: The "data" argument must be of type string or an instance of Buffer, TypedArray, or DataView. Received type number (1617603108.134)
App 5580 output: Warning: unable to write to /var/passenger/passenger.spawn.XXXXb1ACSv/response/steps/subprocess_wrapper_preparation/end_time: The "data" argument must be of type string or an instance of Buffer, TypedArray, or DataView. Received type number (1617603108.134)
App 5580 output: Warning: unable to write to /var/passenger/passenger.spawn.XXXXb1ACSv/response/steps/subprocess_app_load_or_exec/begin_time: The "data" argument must be of type string or an instance of Buffer, TypedArray, or DataView. Received type number (1617603108.135)
App 5580 output: [!] Starting Wig Tools API server...
App 5580 output: [✔] Application middlewares connected
App 5580 output: [✔] Application Routes connected
App 5580 output: [!] Checking For Super admin...
App 5580 output: (node:5580) Warning: Accessing non-existent property 'padLevels' of module exports inside circular dependency
App 5580 output: (Use `node --trace-warnings ...` to show where the warning was created)
App 5580 output: (node:5580) [SEQUELIZE0006] DeprecationWarning: This database engine version is not supported, please update your database server. More information https://github.com/sequelize/sequelize/blob/main/ENGINE.md
App 5580 output: [✔] Super admin already initialized
App 5580 output: Warning: unable to write to /var/passenger/passenger.spawn.XXXXb1ACSv/response/steps/subprocess_app_load_or_exec/begin_time: The "data" argument must be of type string or an instance of Buffer, TypedArray, or DataView. Received type number (1617603109.108)
App 5580 output: Warning: unable to write to /var/passenger/passenger.spawn.XXXXb1ACSv/response/steps/subprocess_app_load_or_exec/end_time: The "data" argument must be of type string or an instance of Buffer, TypedArray, or DataView. Received type number (1617603109.108)
App 5580 output: Warning: unable to write to /var/passenger/passenger.spawn.XXXXb1ACSv/response/steps/subprocess_listen/begin_time: The "data" argument must be of type string or an instance of Buffer, TypedArray, or DataView. Received type number (1617603109.108)
App 5580 output: [✔] Listening on PORT: 30510
App 5580 output: Warning: unable to write to /var/passenger/passenger.spawn.XXXXb1ACSv/response/steps/subprocess_listen/begin_time: The "data" argument must be of type string or an instance of Buffer, TypedArray, or DataView. Received type number (1617603109.111)
App 5580 output: Warning: unable to write to /var/passenger/passenger.spawn.XXXXb1ACSv/response/steps/subprocess_listen/end_time: The "data" argument must be of type string or an instance of Buffer, TypedArray, or DataView. Received type number (1617603109.112)
App 5580 output: [0mGET /products/best-sold [32m200[0m 8.764 ms - 58[0m
App 5580 output: [0mGET /categories [32m200[0m 4.286 ms - 3784[0m

The root public_html is where the main domain points to (www.example.com) which is where i have my htaccess that comes with react build.

the subdomain (api.example.com) has a folder in the public_html by default.

The api subdomain has this (.htaccess) by default

# DO NOT REMOVE. CLOUDLINUX PASSENGER CONFIGURATION BEGIN
PassengerAppRoot "/home/wigtool1/public_html/backend"
PassengerBaseURI "/"
PassengerNodejs "/home/wigtool1/nodevenv/public_html/backend/14/bin/node"
PassengerAppType node
PassengerStartupFile /home/wigtool1/public_html/backend/src/index.js
PassengerAppLogFile "/home/wigtool1/logs/api.log"
# DO NOT REMOVE. CLOUDLINUX PASSENGER CONFIGURATION END
# php -- BEGIN cPanel-generated handler, do not edit
# Set the “ea-php70” package as the default “PHP” programming language.
<IfModule mime_module>
  AddHandler application/x-httpd-ea-php70 .php .php7 .phtml
</IfModule>
# php -- END cPanel-generated handler, do not edit
# DO NOT REMOVE OR MODIFY. CLOUDLINUX ENV VARS CONFIGURATION BEGIN
<IfModule Litespeed>
</IfModule>
# DO NOT REMOVE OR MODIFY. CLOUDLINUX ENV VARS CONFIGURATION END

while the backend is a folder holding the node app that api.example.com points to.

How can I fix this without conflicting

Akinniyi Bode Bolade

I got this solved by using hashRouter in my react app. Rather than using BrowserRouter

import { HashRouter as Router, Route, Switch } from "react-router-dom";

Also, this does not require htaccess to work now, since my server wasn't ngix

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

TOP Ranking

  1. 1

    Failed to listen on localhost:8000 (reason: Cannot assign requested address)

  2. 2

    Loopback Error: connect ECONNREFUSED 127.0.0.1:3306 (MAMP)

  3. 3

    How to import an asset in swift using Bundle.main.path() in a react-native native module

  4. 4

    pump.io port in URL

  5. 5

    Compiler error CS0246 (type or namespace not found) on using Ninject in ASP.NET vNext

  6. 6

    BigQuery - concatenate ignoring NULL

  7. 7

    ngClass error (Can't bind ngClass since it isn't a known property of div) in Angular 11.0.3

  8. 8

    ggplotly no applicable method for 'plotly_build' applied to an object of class "NULL" if statements

  9. 9

    Spring Boot JPA PostgreSQL Web App - Internal Authentication Error

  10. 10

    How to remove the extra space from right in a webview?

  11. 11

    java.lang.NullPointerException: Cannot read the array length because "<local3>" is null

  12. 12

    Jquery different data trapped from direct mousedown event and simulation via $(this).trigger('mousedown');

  13. 13

    flutter: dropdown item programmatically unselect problem

  14. 14

    How to use merge windows unallocated space into Ubuntu using GParted?

  15. 15

    Change dd-mm-yyyy date format of dataframe date column to yyyy-mm-dd

  16. 16

    Nuget add packages gives access denied errors

  17. 17

    Svchost high CPU from Microsoft.BingWeather app errors

  18. 18

    Can't pre-populate phone number and message body in SMS link on iPhones when SMS app is not running in the background

  19. 19

    12.04.3--- Dconf Editor won't show com>canonical>unity option

  20. 20

    Any way to remove trailing whitespace *FOR EDITED* lines in Eclipse [for Java]?

  21. 21

    maven-jaxb2-plugin cannot generate classes due to two declarations cause a collision in ObjectFactory class

HotTag

Archive