BenNG
BenNG

Reputation: 531

serving the folder produce by pub build with the same server that serve the api (complete app)

I would like to join my 2 apps written in dart:

Pretty simple question I know but I don't usually do that, so I was wondering:

Upvotes: 0

Views: 136

Answers (2)

luizmineo
luizmineo

Reputation: 966

You can see an example of full stack Dart application (backend + frontend) here: https://github.com/luizmineo/io_2014_contacts_demo

The server (backend) is configurable, so it can serve the client from any folder (usually, web or build/web). The example also includes a build script, which can be used to produce a deployable build (server + compiled client).

Upvotes: 0

Danny Tuppeny
Danny Tuppeny

Reputation: 42333

If your backend is written such that you have a script in your bin folder that uses HttpRequest then you need to host it in the Dart VM (by calling dart bin\script.dart . You cannot host it as static files like the frontend, because the dart files that should be executed would just be served up to the browser.

Depending on your operating system, you'd likely want to run this as some sort of service to avoid needing a user logged on to run it. The Dart Docker images might be a good way to do this.

If you want to serve the frontend code using the same server, then your backend will need to be able to serve up the static files when handling the request. You might be able to do this easily with the shelf package.

Upvotes: 1

Related Questions