# How make correct post service?

**URL:** <https://discuss.ocaml.org/t/how-make-correct-post-service/16605>\
**Category:** Learning\
**Tags:** eliom, ocsigen\
**Created:** [May 5, 2025, 7:14am UTC](https://discuss.ocaml.org/t/how-make-correct-post-service/16605 "2025-05-05T07:14:19Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![cr4zsci](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/cr4zsci/32/5964_2.png) [@cr4zsci](https://discuss.ocaml.org/u/cr4zsci)\
**Post date:** [May 5, 2025, 7:14am UTC](https://discuss.ocaml.org/t/how-make-correct-post-service/16605/1 "2025-05-05T07:14:19Z")

</div>

i have simple code

```auto
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](http://localhost:8080/users/new)), then saving occurs correctly. Am I doing something wrong?

---

<div class="post-metadata">

**Author:** ![otini](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/otini/32/3533_2.png) [@otini](https://discuss.ocaml.org/u/otini)\
**Post date:** [May 5, 2025, 10:09am UTC](https://discuss.ocaml.org/t/how-make-correct-post-service/16605/2 "2025-05-05T10:09:38Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![cr4zsci](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/cr4zsci/32/5964_2.png) [@cr4zsci](https://discuss.ocaml.org/u/cr4zsci)\
**Post date:** [May 5, 2025, 10:23am UTC](https://discuss.ocaml.org/t/how-make-correct-post-service/16605/3 "2025-05-05T10:23:35Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![cr4zsci](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/cr4zsci/32/5964_2.png) [@cr4zsci](https://discuss.ocaml.org/u/cr4zsci)\
**Post date:** [May 9, 2025, 9:32am UTC](https://discuss.ocaml.org/t/how-make-correct-post-service/16605/4 "2025-05-09T09:32:46Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![cr4zsci](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/cr4zsci/32/5964_2.png) [@cr4zsci](https://discuss.ocaml.org/u/cr4zsci)\
**Post date:** [May 13, 2025, 4:33pm UTC](https://discuss.ocaml.org/t/how-make-correct-post-service/16605/5 "2025-05-13T16:33:09Z")

</div>

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