{"action":"created","issue":{"url":"https://api.github.com/repos/aaronlord/laroute/issues/41","repository_url":"https://api.github.com/repos/aaronlord/laroute","labels_url":"https://api.github.com/repos/aaronlord/laroute/issues/41/labels{/name}","comments_url":"https://api.github.com/repos/aaronlord/laroute/issues/41/comments","events_url":"https://api.github.com/repos/aaronlord/laroute/issues/41/events","html_url":"https://github.com/aaronlord/laroute/issues/41","id":185459558,"number":41,"title":"Determine Root URL at runtime rather than at time of generation.","user":{"login":"mdwheele","id":2453394,"avatar_url":"https://avatars.githubusercontent.com/u/2453394?v=3","gravatar_id":"","url":"https://api.github.com/users/mdwheele","html_url":"https://github.com/mdwheele","followers_url":"https://api.github.com/users/mdwheele/followers","following_url":"https://api.github.com/users/mdwheele/following{/other_user}","gists_url":"https://api.github.com/users/mdwheele/gists{/gist_id}","starred_url":"https://api.github.com/users/mdwheele/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mdwheele/subscriptions","organizations_url":"https://api.github.com/users/mdwheele/orgs","repos_url":"https://api.github.com/users/mdwheele/repos","events_url":"https://api.github.com/users/mdwheele/events{/privacy}","received_events_url":"https://api.github.com/users/mdwheele/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2016-10-26T17:31:34Z","updated_at":"2016-10-26T17:36:03Z","closed_at":null,"body":"Currently, `rootUrl` is compiled from `APP_URL` when `laroute:generate` is executed. As far as I can tell, `rootUrl` is *only ever used* when `laroute.absolute` is `false` (default). Otherwise, it is not needed.\r\n\r\nUsing relative path generation assumes URIs are mounted under the domain name, not considering an application that might be hosted in a subdirectory of that domain. Laravel's UrlGenerator doesn't care much about this because it relies on Symfony's `Request` to generate a correct URI up to the point it takes over. Using absolute URLs when generating is a way around this since JavaScript has no way of telling the difference between what's a subdirectory and what's route.\r\n\r\nHere's my specific problem:\r\n\r\n* I do local development on an application and I serve it from `http://local.dev`. \r\n* My production environment is hosted from `http://example.org/application`.\r\n* I use webpack to handle the bundling of the resultant `laroute.js` file generated by this package. I do not bundle assets in production; thus, the only `.env` available at compile-time is my local one.\r\n\r\nSo, if I pack everything up locally and use absolute URLs, I end up with a production application attempting to query `http://local.dev/generated/path` when in fact, I want `http://example.org/application/generated/path`. Previous to discovering this package, I was doing something fairly similar: creating a JavaScript object populated with data from the backend. The difference was that I didn't need to support parameterized routes during prototyping and now I do, so I'm delighted to find this package! 😁 \r\n\r\nHowever, I would like to contribute a means of determining root URL at runtime, based on either the `.env#APP_URL` configuration OR by generating it and disregarding what is in `.env#APP_URL`. \r\n\r\nAll this to say, would you be interested in such a contribution and if so, do you have any specific constraints towards development? I've got a local patch that works for me but it requires something like this in my base template (which actually works alright and is reasonable, to me):\r\n\r\n```\r\n<script src=\"{{ asset(\"public/js/laroute.js\") }}\"></script>\r\n<script>\r\n    laroute.config.rootUrl = \"{{ env('APP_URL') }}\"\r\n</script>\r\n```\r\n\r\nEssentially, exposing configuration to userland to be changed at runtime, while also allowing compile-time generation from your published vendor configuration."},"comment":{"url":"https://api.github.com/repos/aaronlord/laroute/issues/comments/256422008","html_url":"https://github.com/aaronlord/laroute/issues/41#issuecomment-256422008","issue_url":"https://api.github.com/repos/aaronlord/laroute/issues/41","id":256422008,"user":{"login":"mdwheele","id":2453394,"avatar_url":"https://avatars.githubusercontent.com/u/2453394?v=3","gravatar_id":"","url":"https://api.github.com/users/mdwheele","html_url":"https://github.com/mdwheele","followers_url":"https://api.github.com/users/mdwheele/followers","following_url":"https://api.github.com/users/mdwheele/following{/other_user}","gists_url":"https://api.github.com/users/mdwheele/gists{/gist_id}","starred_url":"https://api.github.com/users/mdwheele/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mdwheele/subscriptions","organizations_url":"https://api.github.com/users/mdwheele/orgs","repos_url":"https://api.github.com/users/mdwheele/repos","events_url":"https://api.github.com/users/mdwheele/events{/privacy}","received_events_url":"https://api.github.com/users/mdwheele/received_events","type":"User","site_admin":false},"created_at":"2016-10-26T17:36:03Z","updated_at":"2016-10-26T17:36:03Z","body":"Related: https://github.com/aaronlord/laroute/pull/20"}}
{"actor":{"display_login":"mdwheele"}}