Christiano
01/19/2024, 9:56 PM/projects/?projectId=2
.
Running kobweb locally serves the correct page with the correct information. But when exported to a static site I just get a white page with Error 404
on it.
However... my homepage has the ability to fetch specific category of projects with path /?categoryId=2
and that one route does work, both locally and when exported to static files...
Is this an issue because a static can not have query parameters? Or should I be looking at another issue? π€
What I understood that a static site could not support was dynamic paths like /projects/{projectId}/
, so I'm a bit lost I'm afraid π
David Herman
01/19/2024, 10:00 PMkobweb run
?David Herman
01/19/2024, 10:00 PM.kobweb
? In your site resources?Christiano
01/19/2024, 10:03 PMstaticFiles("/", File("site"))
in ktor. I omitted the .js
and .js.map
files in this snippetDavid Herman
01/19/2024, 10:03 PMDavid Herman
01/19/2024, 10:04 PM/projects/?projectId=2
should workDavid Herman
01/19/2024, 10:04 PMDavid Herman
01/19/2024, 10:06 PMChristiano
01/19/2024, 10:12 PMsite
folder) and then tell ktor to serve it by using staticFiles("/", File("site"))
After that I run ktor locally and just navigate to localhost:8080
and just use the site like normal. When I notice that my link to the detail page does not work, I try out some other versions of the path. For example: /projects?projectId=2
or /projects/projectId=2
and also /projects
.
The last one actually renders my page, but because it doesn't find a parameter it won't show the correct data. The other 2 just give an error. The first one just gives a white page with Error 404
(which I think is just an error of ktor itself?). The second one gives another error stating No web page was found for the web address: localhost:8080*/projects/?projectId=2*
David Herman
01/19/2024, 10:13 PMindex.html
directly πChristiano
01/19/2024, 10:13 PMDavid Herman
01/19/2024, 10:13 PMDavid Herman
01/19/2024, 10:15 PMChristiano
01/19/2024, 10:15 PMDavid Herman
01/19/2024, 10:16 PMDavid Herman
01/19/2024, 10:17 PMDavid Herman
01/19/2024, 10:17 PMDavid Herman
01/19/2024, 10:18 PM// "example/" should resolve to "example/index.html" if present, but default ktor behavior rejects trailing slashes.
this.install(IgnoreTrailingSlash)
David Herman
01/19/2024, 10:18 PMthis
is an Application
)David Herman
01/19/2024, 10:18 PMChristiano
01/19/2024, 10:24 PMindex.html
doesn't seem to work π
Also, would it mabye be needed to have every folder as a separate staticFile like this? π€
staticFiles("/", File("site"), index = "index.html")
staticFiles("/projects", File("site/projects"), index = "index.html")
Christiano
01/19/2024, 10:24 PMDavid Herman
01/19/2024, 10:25 PMDavid Herman
01/19/2024, 10:25 PMDavid Herman
01/19/2024, 10:26 PMDavid Herman
01/19/2024, 10:26 PMChristiano
01/19/2024, 10:27 PMChristiano
01/19/2024, 10:39 PMthis.install(IgnoreTrailingSlash)
, this path actually works <http://localhost:8080/projects/?projectId=1>
π€ π
And trying out this path <http://localhost:8080/projects?projectId=1>
(without trailing slash), actually show the page for a split second and then just plainly shows Error code: 404
on a white page π
Update:
When deploying it to Render I had to use staticResources("/", "/static/site")
. For some reason staticFiles(...)
wasn't serving any files... Could've been my fault, but for now it works and it's okay. Gonna take another look at it some other time!
Thanks for thinking with me and providing me with the trailingSlash fix! π
David Herman
01/20/2024, 12:04 AMDavid Herman
01/20/2024, 12:05 AMChristiano
01/20/2024, 8:53 AMDavid Herman
01/20/2024, 7:31 PMDavid Herman
01/20/2024, 7:31 PMDavid Herman
01/20/2024, 7:32 PMENTRYPOINT .kobweb/server/start.sh
which is just this script: https://github.com/varabyte/kobweb/blob/14e9ccffb889907cb3ee9d94a0c3e90c3d33db74/t[β¦]obweb/gradle/application/tasks/KobwebCreateServerScriptsTask.ktDavid Herman
01/20/2024, 7:32 PMDavid Herman
01/20/2024, 7:33 PMChristiano
01/21/2024, 10:21 AM