Code Monkey home page Code Monkey logo

Comments (3)

srevenant avatar srevenant commented on July 20, 2024

In the end, I'm not exactly certain where my configurations were wrong because I tried so many variations. But for anybody else facing this problem, the code has zero logging. What I ended up doing was editing deps/cors_plug/lib/cors_plug.ex, and putting |> IO.inspect into places around init and pulling up the configs, then running queries until I was able to find exactly how things matched. Difficult, but workable.

from cors_plug.

mschae avatar mschae commented on July 20, 2024

I’ll glad you figured it out knowing full well how frustrating these things can be.

I would’ve recommended what you ended up doing anyway which is editing the source lib. I don’t think there’s a good way to add generic logging as in most cases it’d just be noise.

Thanks for sharing your journey tho, I’ll keep it in mind if there’s ever a discussion around or need for logging.

from cors_plug.

srevenant avatar srevenant commented on July 20, 2024

@mschae I would suggest adding something to the docs around how to debug this. I know I've worked with others who've been equally frustrated. Even just instructions on how to do inline debugging. I.e. go to line ... and add |> IO.inspect, etc, if you are not seeing it match the output you are expecting.

What is most important:

  • It only pays attention to the origin header -- which is client submitted and has no relation to conn.remote_ip. To see this add a debug |> IO.inspect to request_origin around line 159.
  • Visually identify how that compares to what is actually coming into the configs, by adding something around the stages of init to verify your configurations are merging in correctly.

But honestly you could add debug/log function easily enough as a configuration option that logs these same things, then just add a default that disables it, where the config can add it in.

For whatever reason, I have noticed that the libs in Elixir are frighteningly low on debugging/logging capabilities. I suspect it's, in part, the nature of people wanting to optimize the pattern matching pipelines, without adding extra heuristics. But the side effect of this is a high barrier to entry for new developers, many I even know who just give up and go back to something a little more user-friendly.

from cors_plug.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.