How to serve a reactjs SPA with browserHistory router?

Hello,

I’m try using caddy to serve my reatjs single page app which use react-router with browerHistory.

I want caddy handle static files first, then if not found rewrite to /index.html

Could caddy handle it?

Thanks

Have a look at the Caddy rewrite docs - you’re after the block version, specifically the to subdirective.

1 Like

Thanks. It’s helpful.

`
0.0.0.0:80

root /var/www/html

log stdout

errors stdout

rewrite / {
to {path} /
}
`
I have done it with this configure.

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