With this configuration I can serve static HTML.
I can not find a working configuration for my react-app. It uses react-router. I found examples like this: https://stackoverflow.com/questions/57772701/how-to-configure-caddy-server-for-react-router
But they are using the Caddyfile. I would like to use the JSON config.
Are there examples for a working JSON configuration with React apps?
4. Error messages and/or full log output:
If I try to load the React App with this configuration, Chrome serves a blank page with these errors in the console:
Error handling response: TypeError: Cannot read property 'isMSE' of null
at chrome-extension://flliilndjeohchalpbbcdekjklbdgfkk/js/content/content.js:5693:12
at chrome-extension://flliilndjeohchalpbbcdekjklbdgfkk/js/content/content.js:2506:13
localhost:2015/%PUBLIC_URL%/favicon.ico:1 Failed to load resource: net::ERR_HTTP2_PROTOCOL_ERROR
manifest.json:1 Failed to load resource: net::ERR_HTTP2_PROTOCOL_ERROR
5. What I already tried:
I have no clue how to use the rewrite function with the JSON config. It is unclear to me on how to translate the Caddyfile examples to JSON.
I concur - the best way to learn how to write JSON in my opinion is to first write a simple Caddyfile for what you want, then use the caddy adapt command to get the JSON for it.
For example, this is probably the Caddyfile for what you’re wanting:
This works also with other Computers in the local network without complaints about the SSL Certificate. All there is to do is to trust the root certificate that Caddy has generated on the other LAN Computers.