Fork me on GitHub
#pedestal
<
2019-01-31
>
ccann17:01:55

@donaldball you could also set interceptors at the server config level with the key :io.pedestal.http/interceptors with a vector of common interceptors, if that factoring works for your setup

ccann17:01:23

so my routes looks like this:

(def routes
  #{["/custom/notes"                     :get   [auth    owner    `notes/filter-by-user]]
    ["/custom/notes"                     :post  [auth-un any-user `notes/create-one]]
    ["/custom/notes/:id"                 :get   [auth    owner    `notes/read-one]]
    ["/custom/notes/:id"                 :patch [auth-un owner    `notes/update-one]]
    ["/custom/notes/:id/graphic"         :get   [auth    owner    `notes/read-graphic]]
    ["/custom/notes/:id/production-file" :post  [auth    owner    `notes/create-production-file]]
    ["/custom/health_check"              :get   `healthy]})


(def interceptors
  [(multipart-params)
   (body-params)
   json-body
   authorization
   exception-handler])

ccann17:01:53

where the interceptors vector is pulled into the server config

caleb.macdonaldblack22:01:54

I'm trying to access my pedestal service from my web app but the preflight OPTIONS request returns a 404. A GET request to the same url works. I haven't had this issue before when using pedestal in the past. Any ideas what silly little thing I'm missing is?

ccann22:01:36

could it be a CORS issue?

caleb.macdonaldblack22:01:11

Actually yeah. I need to provide ::http/allowed-origins

caleb.macdonaldblack22:01:06

I thought it wouldn't be an issue as I'm hosting pedestal on the same domain. But it looks like it won't deal with preflight at all if it doesn't have that key