Another question for the community. I've noticed t...
# kobweb
r
Another question for the community. I've noticed that when using dynamic routes, the route is not found when I directly access it (as in, I paste the full URL into the address bar), but when I use the relative link to access it, the route is found. Has anyone else had this issue?
d
Are you talking about when developing locally? Or is this in production?
r
The specific example is this: https://www.fsryan.com/people -> click on ryan That routes you to https://www.fsryan.com/people/ryan However, if you were to paste that in the address bar, the route is not found.
This is the signature of the composable function for the page:
Copy code
@Page("/people/{personId}")
@Composable
fun PersonPage() {
d
Are you running your own ktor server, a Kobweb server, or is it some third party solution?
r
I'm running my own.
It's running in a docker container on linode.
d
Running your own custom server or a Kobweb server?
r
A kobweb server.
d
Let me try later today, it could be a bug. The Kobweb server is definitely supposed to handle dynamic routes assuming it's not a static layout export
r
Here's my Dockerfile:
Copy code
FROM azul/zulu-openjdk:17.0.11-jdk

# In order to use this, the site must be pre-built

RUN mkdir /app
WORKDIR /app

# curl is used to download the cobweb-cli tarball.
RUN apt-get update && apt-get install -y curl

# the URL is actually a redirect; -L enables curl to follow the redirect and download the actual file
RUN curl -L -s -O <https://github.com/varabyte/kobweb-cli/releases/download/v0.9.15/kobweb-0.9.15.tar>
RUN tar -xf kobweb-0.9.15.tar && rm kobweb-0.9.15.tar
ENV PATH /app/kobweb-0.9.15/bin:$PATH

# Copy the necessary files below to use gradle to build the site
COPY . .

# exports the site and exposes the port based upon the site's configuration
RUN export PORT=$(kobweb conf --path site server.port)
EXPOSE $PORT

# Removes the packages we installed (with their dependencies because they are no longer needed
RUN apt-get purge --auto-remove -y curl && rm -rf /var/lib/apt/lists/*

# Starts up the site in production mode
CMD kobweb run --path site --notty --env prod --foreground --layout static
d
Oh yeah you're running a static layout. You probably want
fullstack
layout in your case
The static layout is for mimicking dumb servers that don't have API endpoints
r
Well--it doesn't have an API endpoint--it's just that I have multiple people that have profiles.
But I think you're onto something with how this is hosted.
d
If you have dynamic routes that's probably a good enough reason
r
because locally, just pasting in the url works.
d
It should be an easy fix for you -- try exporting with the fullstack layout and run it in your Dockerfile
r
Sure.
d
With Kobweb, once you successfully download and run the site, then everything works locally at that point, including dynamic routes
However requesting the site in the first place is tricky with dynamic routes
r
Just a quick follow-up. That worked.
👍 1
At least in the docker container I am running locally, it worked--which should mean it works the same way with the one I deploy.