Search code examples
reactjselixirphoenix-frameworkguardian

(RuntimeError) `module` not set in Guardian pipeline . How to fix this?


Github link of my project.

The Tutorial I am following

This is error on my terminal for api(phoenix server)

[error] #PID<0.560.0> running Slicker.Endpoint terminated
Server: localhost:4000 (http)
Request: POST /api/users
** (exit) an exception was raised:
    ** (RuntimeError) `module` not set in Guardian pipeline
        lib/guardian/plug/pipeline.ex:240: Guardian.Plug.Pipeline.raise_error/1
        lib/guardian/plug/verify_header.ex:84: Guardian.Plug.VerifyHeader.call/2
        (slicker) web/router.ex:12: Slicker.Router.api/2
        (slicker) web/router.ex:1: Slicker.Router.match_route/4
        (slicker) web/router.ex:1: Slicker.Router.do_call/2
        (slicker) lib/slicker/endpoint.ex:1: Slicker.Endpoint.phoenix_pipeline/1
        (slicker) lib/plug/debugger.ex:123: Slicker.Endpoint."call (overridable 3)"/2
        (slicker) lib/slicker/endpoint.ex:1: Slicker.Endpoint.call/2
        (plug) lib/plug/adapters/cowboy/handler.ex:15: Plug.Adapters.Cowboy.Handler.upgrade/4
        (cowboy) /media/ankit/FE3055EB3055AB81/project/slicker/api/deps/cowboy/src/cowboy_protocol.erl:442: :cowboy_protocol.execute/4


Solution

  • I think you need to add this to your pipeline:

    plug Guardian.Plug.Pipeline, module: App.Guardian, error_handler: App.Web.SessionController
    

    You should also check that you're using the same version of Guardian that the tutorial is using. They introduced many changes to the 1.0 release of Guardian compared to previous versions of the library.