Hello, could someone please help me with the final step/steps of getting started with Caddy?
I want to host my sveltekit app. I´m completely new to this whole server stuff so please bear with me! I assume I have either missed some step or something wrong in my config file? Or pointing to the wrong map/file?
I have git cloned my repo and added it to /var/www and then i built it.
2. Error messages and/or full log output:
404 couldnt be found. I think some time it also said too many redirects but not 100% sure.
3. Caddy version:
2.6.4
4. How I installed and ran Caddy:
Through the Ubuntu command lines guide (caddys guide)
a. System environment:
Ubuntu 22.04 and trying to run a Sveltekit app
b. Command:
(for my app)
npm install
npm run build
(for caddy)
sudo systemctl start caddy
sudo systemctl restart caddy
You have to use a static adapter and tell svelte-kit that you want to use a static build:
# Create the svelte (kit) app
$ npm create svelte@latest myapp
$ cd myapp
$ npm install
# Install the adapter and tell svelte to use it
$ npm i @sveltejs/adapter-static
$ cat svelte.config.js
import adapter from "@sveltejs/adapter-static";
export default {
kit: {
adapter: adapter({
// default options are shown. On some platforms
// these options are set automatically — see below
pages: "build",
assets: "build",
fallback: null,
precompress: false,
strict: false,
}),
},
};
# build the project statically
$ npm run build
# Fire the mighty Caddy telling it to serve files statically for hostname localhost
$ cat Caddyfile
localhost {
root * ./build
file_server
}
$ caddy run
...
Not sure how that is possible with the caddy file you showed. The node adapter works at network level (listens) and your caddy file tells caddy to serve static files.
On this last one, you are telling Caddy to proxy the requests to your node server. Caddy is opening a socket to the node server and proxing the requests. In the first Caddyfile, you instructed caddy to map request to files in file system. No networking there. That is why I was confused.