Fork me on GitHub
#aws
<
2022-02-05
>
Ben Hammond22:02:34

I have a webpage hosted in an S3 Bucket and using Static Website Hosting I recently switched to using BrowserRouter style URLs eg instead of but now I have the problem that S3 wants to service the logged-in URL from the (non-existant) public/logged-in file whereas I want it to be directed to the cljs app at and let react router pick up the specifics Can I do this with S3 static website hosting?

Ben Hammond23:02:02

I am trying to use io.pedestal.http.ring-middlewares.cookies with io.pedestal.ions using http-direct datomic-ions but I see the error

"Msg": "http-endpoint respond failed: ",
    "Ex": {
        "Via": [
            {
                "Type": "java.lang.ClassCastException",
                "Message": "class clojure.lang.LazySeq cannot be cast to class java.lang.String (clojure.lang.LazySeq is in unnamed module of loader 'app'; java.lang.String is in module java.base of loader 'bootstrap')",
                "At": [
                    "cognitect.http_endpoint.jetty$respond_bbuf_STAR_",
                    "invokeStatic",
                    "jetty.clj",
                    342
                ]
            }
        ],
I strongly suspect that this is because ring.middleware.cookies/write-cookies is outputting a Set-Cookies Header like
"Set-Cookie" ("__HostID=eyJr***;Secure;HttpOnly;Expires=Mon Mar 07 22:58:14 UTC 2022;Path=/\")
does this mean that I am using the cookies interceptor wrongly? Is there some io.pedestal.ions shim that I should be applying? Do I have to write my own shim?

Ben Hammond23:02:01

so I can make this particular problem go away by writing

(def cookiehack-interceptor
  (interceptor/interceptor
   {:name ::cookiehack-interceptor
    :leave
    (fn [ctx]
      (if-let [cookies (get-in ctx [:response :headers "Set-Cookie"])]
        (cond (string? cookies) ctx
              (seq? cookies) (assoc-in ctx [:response :headers "Set-Cookie"] (first cookies))
              :else ctx)
        ctx))
    }))
is there a better way to solve this..?

Ben Hammond23:02:48

(it looks like (string/join \, cookies) is discouraged...)