{"action":"created","issue":{"url":"https://api.github.com/repos/phoenixframework/phoenix/issues/1036","labels_url":"https://api.github.com/repos/phoenixframework/phoenix/issues/1036/labels{/name}","comments_url":"https://api.github.com/repos/phoenixframework/phoenix/issues/1036/comments","events_url":"https://api.github.com/repos/phoenixframework/phoenix/issues/1036/events","html_url":"https://github.com/phoenixframework/phoenix/issues/1036","id":96057961,"number":1036,"title":"Splat route vs Plug.Static problem?","user":{"login":"tmjoen","id":10501945,"avatar_url":"https://avatars.githubusercontent.com/u/10501945?v=3","gravatar_id":"","url":"https://api.github.com/users/tmjoen","html_url":"https://github.com/tmjoen","followers_url":"https://api.github.com/users/tmjoen/followers","following_url":"https://api.github.com/users/tmjoen/following{/other_user}","gists_url":"https://api.github.com/users/tmjoen/gists{/gist_id}","starred_url":"https://api.github.com/users/tmjoen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tmjoen/subscriptions","organizations_url":"https://api.github.com/users/tmjoen/orgs","repos_url":"https://api.github.com/users/tmjoen/repos","events_url":"https://api.github.com/users/tmjoen/events{/privacy}","received_events_url":"https://api.github.com/users/tmjoen/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":7,"created_at":"2015-07-20T12:56:58Z","updated_at":"2015-07-20T15:08:23Z","closed_at":null,"body":"In my app, I serve a `priv/media` directory through an additional `Plug.Static` in my endpoint.ex\r\n\r\n```elixir\r\n  plug Plug.Static,\r\n    at: \"/media\", from: \"priv/media\"\r\n```\r\n\r\nThis works fine.\r\n\r\nHowever, when I add a splat route like this:\r\n\r\n```elixir\r\n  # router.ex\r\n\r\n    get \"/:language/instagram\", Neva.InstagramController, :index\r\n    get \"/:language/*key\", Neva.PageController, :show\r\n```\r\n\r\nI start seeing some weird behaviour with my `/media` resources. Sometimes/randomly some of the images refuse to load, trying to go the splat route (PageController :show) instead of being handled by the `Plug.Static` for /media.\r\n\r\nWhen I right click the failed image, and try to reload it in a new tab - it works. The image is there, it just takes a wrong route trying to find it!\r\n\r\nIf I change the splat route so there are no chances of confusion:\r\n\r\n```elixir\r\n   # router.ex\r\n\r\n    get \"/n/:language/instagram\", Neva.InstagramController, :index\r\n    get \"/n/:language/*key\", Neva.PageController, :show\r\n```\r\n\r\nIt works fine again. Sometimes I don't see this bug for days, then suddenly it shows up all the time.\r\n\r\nI realize this is almost impossible to debug, but I thought I'd raise an issue here and see if anything jumped to your minds."},"comment":{"url":"https://api.github.com/repos/phoenixframework/phoenix/issues/comments/122913448","html_url":"https://github.com/phoenixframework/phoenix/issues/1036#issuecomment-122913448","issue_url":"https://api.github.com/repos/phoenixframework/phoenix/issues/1036","id":122913448,"user":{"login":"tmjoen","id":10501945,"avatar_url":"https://avatars.githubusercontent.com/u/10501945?v=3","gravatar_id":"","url":"https://api.github.com/users/tmjoen","html_url":"https://github.com/tmjoen","followers_url":"https://api.github.com/users/tmjoen/followers","following_url":"https://api.github.com/users/tmjoen/following{/other_user}","gists_url":"https://api.github.com/users/tmjoen/gists{/gist_id}","starred_url":"https://api.github.com/users/tmjoen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tmjoen/subscriptions","organizations_url":"https://api.github.com/users/tmjoen/orgs","repos_url":"https://api.github.com/users/tmjoen/repos","events_url":"https://api.github.com/users/tmjoen/events{/privacy}","received_events_url":"https://api.github.com/users/tmjoen/received_events","type":"User","site_admin":false},"created_at":"2015-07-20T15:08:23Z","updated_at":"2015-07-20T15:08:23Z","body":"I set up an automatic reloader on two different machines just refreshing the same page over and over and the error turns up randomly.\r\n\r\nThen I inspected  the [path in Plug.Static](https://github.com/elixir-lang/plug/blob/master/lib/plug/static.ex#L124)\r\n\r\nit is relative for my media/ Plug.Static:\r\n\r\n`\"priv/media/images/instagram/large/11379309_784422001656659_909160896_n.jpg\"`\r\n\r\nwhile it is absolute for my static/ Plug.Static\r\n\r\n`\"/Users/tmjoen/dev/elixir/neva/_build/dev/lib/neva/priv/static/fonts/bootstrap/glyphicons-halflings-regular.woff2\"`\r\n\r\nIf I change my Plug.Static setup to\r\n\r\n```elixir\r\n  plug Plug.Static,\r\n    at: \"/media\", from: {:neva, \"priv/media\"}\r\n```\r\n\r\nmy media also has absolute paths and the problem seems to go away. So I guess there's some weird stuff going on with relative paths there?\r\n"}}