-
Notifications
You must be signed in to change notification settings - Fork 109
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Subdirectory installs: API urls are not generated correctly #202
Comments
Hi! Surely your |
Or alternatively, what Laravel settings are you using to tell Laravel that it is hosted under the |
Would seem that this needs to be supported, but we cannot removed the detection of the host because otherwise it will break the host working correctly on wildcard sub-domains. Changing that line to pass a second argument as |
Yes, absolutely. setting |
If the namespace is going to vary per installation, then using an ENV setting would be most appropriate. E.g. set the namespace configuration option to: 'namespace' => env('JSON_API_NAMESPACE', '/app/api/v1') It would help me out though if you could tell me how you handle normal routing. E.g. if your application had a Route::get('/app/home', 'HomeController@home'); |
Using an ENV setting is an excellent idea, thank you! I can't believe I didn't think of that. I am going do some testing just now as I note that As for normal routing, I am using the following.
|
Using an ENV setting caused routing errors. I propose an alternative solution combining Symfony's |
Thanks for investigating this. Can't see how to add tests for it unfortunately so have just merged it for the moment as it doesn't break any existing stuff as far as I can see. In terms of I'm planning to release this change and another as composer require cloudcreativity/laravel-json-api:dev-master I don't make breaking changes to |
Released in |
Thank you for resolving this so quickly. Much appreciated. |
If the Laravel application is installed in a subdirectory, URLs (e.g. self and related) are generated relative to the domain rather than the application URL.
Consider an API being served from
https://example.org/app/
with the following default configuration inconfig/json-api-default.php
.API results look like:
The links should respect the application URL and be of the form
https://example.org/app/api/v1/posts/2
.It seems that this issue may be caused by the use of
getSchemeAndHttpHost()
from the Symfony HttpFoundation package inHttp\Middleware\BootJsonApi.php
(lines 77 and 78).If we set the second argument to
null
, urls are generated correctly.The text was updated successfully, but these errors were encountered: