Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Epic: Allow Kobweb to work in cases where it doesn't own the server #22

Open
2 of 5 tasks
bitspittle opened this issue Oct 1, 2021 · 4 comments
Open
2 of 5 tasks
Labels
enhancement New feature or request
Milestone

Comments

@bitspittle
Copy link
Collaborator

bitspittle commented Oct 1, 2021

To check off items on this list, they should both be supported AND documented

Static support

These items probably just need files to be exported a certain way

  • GCP
  • Netlify

Dynamic support

These items probably need logic currently backed into the kobweb/backend codebase refactored out into a shareable JVM library and then implemented per target

  • ktor
  • Spring Boot

Other

I'm not familar with these technologies at this point so they will require a bit more investigation to categorize / understand properly


Original comment:

Feedback from the community: "end to end does provide a better headstart experience. but afaik backend is super complex so integrating it w/ something like spring boot would make it a lot more feasible for many use cases"

@bitspittle bitspittle added the enhancement New feature or request label Oct 1, 2021
@bitspittle bitspittle added this to the 1.1 milestone Feb 6, 2022
@bitspittle bitspittle changed the title Integrate with Spring Boot Allow Kobweb to work in cases where it doesn't own the server Feb 7, 2022
@bitspittle bitspittle changed the title Allow Kobweb to work in cases where it doesn't own the server Epic: Allow Kobweb to work in cases where it doesn't own the server Feb 8, 2022
bitspittle added a commit that referenced this issue Feb 9, 2022
This should make it possible for users to export their site in
a format easy to deploy on a static hosting site, e.g. Netlify

This disables some of the features that make Kobweb powerful
(e.g. dynamic routes and server API routes), but for many use
cases, e.g. portfolios or blog sites, this is fine.

Bug #22
bitspittle added a commit that referenced this issue Feb 10, 2022
This should make it possible for users to export their site in
a format easy to deploy on a static hosting site, e.g. Netlify

This disables some of the features that make Kobweb powerful
(e.g. dynamic routes and server API routes), but for many use
cases, e.g. portfolios or blog sites, this is fine.

Bug #22
@bitspittle
Copy link
Collaborator Author

bitspittle commented Jun 28, 2023

Note that a "workaround" for people running their own servers is to serve the Kobweb site themselves.

@NorbertSandor
Copy link

NorbertSandor commented Jun 1, 2024

I already use Kobweb on the client side - it is great :)
It would be nice if I could use live reloading support during development but also be able to use my Ktor-based backend which I cannot (and don't want to) replace.

@bitspittle
Copy link
Collaborator Author

@NorbertSandor hey, since you have a real case, I have a question for you. If I allowed you to set up my Kobweb server to act as a proxy for your server, would that work for you?

Getting live reloading to work for your custom server probably won't ever happen (getting it right takes a fair bit of custom code, see here which if you dig in does some fancy classloader tricks and makes some assumptions).

That said, if I add proxy support to Kobweb servers, you could start up a Kobweb server and ALSO spin up your custom server, and have Kobweb configured to point at it.

If you rebuild / restart your server, then you kind of get a live reloading experience, as the existing Kobweb server will just keep delegating to whatever is running.

@NorbertSandor
Copy link

NorbertSandor commented Jun 2, 2024

set up my Kobweb server to act as a proxy for your server

This is how I currently use the Webpack Devserver:

  • the Webpack-generated JS files are served directly by the Devserver
  • everything else (resources, HTTP endpoints, WebSocket endpoints) is served by my own Ktor backend, proxyied by the Devserver

So currently my Kotlin/JS webapp communicates directly only with the Devserver.
It means I currently spin up 2 servers during development - and I have no problem with it :).

live reloading to work for your custom server probably won't ever happen

I see...
The reason I want to give a try to Kobweb (besides that I already use the Modifier-system and other lower-level features) is that I'm not satisfied with how the Kotlin - Webpack Devserver integration works (or often not works in my case).
I have already tried the generated "hello-world" Kobweb project but I want to try somehow how it would work with my complex multi-project application.

That said, if I add proxy support to Kobweb servers, you could start up a Kobweb server and ALSO spin up your custom server

This is exactly how I currently use the Webpack Devserver.
It proxies everything to my backend except the generated JS files.
So yes, it would probably work.

Just one question: wouldn't it be really big work to implement a HTTP+WS proxy from stratch?
Or do you know a (Ktor-based) ready-to-integrate alternative?

Another idea has just popped in my head, namely to avoid HTTP/WS proxying entirely:

  1. I could refactor my Kotlin/JS webapp to call my backend directly instead of letting the Webpack Devserver to proxy my connections.
  2. Then I will try to convert the webapp to Kobweb (and replace Webpack-related Gradle tasks like jsBrowserDevelopmentRun with Kobweb tasks).

If I allowed you to set up my Kobweb server to act as a proxy for your server

The reason I don't want you to implement this proxying functionality right now is because I'm not sure that I can successfully convert my app to Kobweb, and I don't want you to work unnecessarily. It is because my biggest problem is not the proxying: my webapp owns the entire application logic, starting from a suspend main() function (it starts a DI container, makes various initializations, etc.), so it will be probably non-trivial to convert it to Kobweb - I don't know if I can do it at all :( (so currently I'm just collecting information about all related tasks, before even starting this huge refactoring).

But thanks for the insights, and giving me the above idea :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants