Caddy and React app

Hi all,

I have a React app with React router that I am trying to host using Caddy. It is on an EC2 box: pretty vanilla set up.

The app works properly with python3 -m http.server so I’m not sure why it does not work with Caddy. Running Caddy locally with the same Caddyfile doesn’t work either. Can anybody help me to debug this? It seems like I’m missing something with Caddy that is causing my React app/js files to not serve correctly.

Production site is here:

Caddyfile looks like this. Index file is hosted at root/admin, and caddy is run from the root directory (parent directory of /admin). {
    root admin
    log ./access.log

    errors {
      404 index.html

Thanks in advance

Fixed by adding this:
<Route path="*" component={() => <App store={userStore}/>}/>

It seems Caddy treats trailing URLs differently from python or node web server.

The above catch all route fixed the issue—React wasn’t able to match any routes when I hit /

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.