How make correct post service?

i have simple code

open Eliom_content.Html.D
open Eliom_service
open Eliom_parameter

module App = Eliom_registration.App (struct
    let application_name = "eliom_playground"
    let global_data_path = None
  end)

let page_skeleton content =
  Lwt.return @@ html (head (title (txt "")) []) (body [content])

let users_list = create ~path:(Path ["users"; "list"]) ~meth:(Get unit) ()
let user_form = create ~path:(Path ["users"; "new"]) ~meth:(Get unit) ()

let submit_user_form =
  create
    ~path:(Path ["users"; "new"])
    ~meth:(Post (unit, string "name" ** string "fname" ** string "lname"))
    ()

type user = {name : string; fname : string; lname : string}

let users : user list ref = ref []

let () =
  App.register ~service:users_list (fun () () ->
    let rows =
      List.map
        (fun u -> tr [td [txt u.name]; td [txt u.fname]; td [txt u.lname]])
        !users
    in
    div [a ~service:user_form [txt "add user"] (); table rows] |> page_skeleton);
  App.register ~service:user_form (fun () () ->
    let fields name fname lname =
      [ Form.input ~input_type:`Text Form.string ~name
      ; Form.input ~input_type:`Text Form.string ~name:fname
      ; Form.input ~input_type:`Text Form.string ~name:lname
      ; Form.input ~input_type:`Submit Form.string ]
    in
    Form.post_form ~service:submit_user_form
      (fun (name, (fname, lname)) -> fields name fname lname)
      ()
    |> page_skeleton);
  App.register ~service:submit_user_form (fun () (name, (fname, lname)) ->
    users := {name; fname; lname} :: !users;
    h1 [txt "user created"] |> page_skeleton)

After going to the form via a link from the list of users and sending the data, I get an error in the console: “[eliom:request] can’t silently redirect a Post request to non application content”. In the developer console I see that requests to save form data are sent not to localhost, but to the host name, and with a missing port (in this case 8080). If I open the form at its address (http://localhost:8080/users/new), then saving occurs correctly. Am I doing something wrong?

How do you start the server? I experienced no such problem by running make test.opt (or make test.byte).

I create the app using the command eliom-distillery -name eliom_playground -template app.exe and replace eliom_playground.eliom with my code. I start the server using make test.byte.

I noticed that when creating a form via a link, a base tag with host name is added to the page header. When going directly to the form page, there is no such tag. That’s the problem.

the problem was solved by changing the server parameter useddefaulthostname to false