phoenixframework / phoenix_live_reload

Provides live-reload functionality for Phoenix
MIT License
315 stars 90 forks source link

Handle script_name when matching paths #30

Closed chrismccord closed 8 years ago

chrismccord commented 8 years ago

We had the report of an issue with mounting phoenix at a path, using the path: Endpoints url path option. The "/phoenix/live_reload" frame would 404 because it does not take script_name into consideration with the path. @josevalim 2nd pair of eyes please.

josevalim commented 8 years ago

:+1:

josevalim commented 8 years ago

Wait, I actually disagree. If you are mounting it inside a path, maybe you should access it inside that path?

josevalim commented 8 years ago

I.e. instead of changing the matching code, I would change the generating code to consider script_name, around here: https://github.com/phoenixframework/phoenix_live_reload/pull/30/files#diff-c8be1eead197c8e20eb612e511f68033R69

josevalim commented 8 years ago

Something like: config[:url] || ("/" <> Enum.join(conn.script_name, "/"))

That's similar to how our URL helpers would work too, we would just generate links inside the given script name.

chrismccord commented 8 years ago

@josevalim Thanks and good call. Updated. Now a user can explicitly include the path prefix in their endpoint:

socket "/some_path/phoenix/live_reload/socket", Phoenix.LiveReloader.Socket

Is this what you had in mind?