Jump to content

[SOLVED] Extend API with httpUrl()


Noel Boss
 Share

Recommended Posts

Maybe I'm missing something here, but I'm haveing a hard time to get absolute urls if PW is installed in a subdirectory thought the API...

I need an absolute URL for the backend (as a redirect url of Oauth provider). To build the url i would normaly use

url()->root.url()->admin – but this results in the install-path beeing present twice;

domain.com/path/ + path/admin/

In order to not use $_SERVER['HTTP_HOST'] I fetch the admin page from pages – but this is also not to easy since I need to remove the root folder from path as well. My current solution is somewhat complicated:

$backendUrl = pages()->get('path="'.str_replace(urls()->root, '', urls()->admin).'", include=all')->httpUrl;

The above code seems to be the savest way to get the absolute url to the backend using pure PW API, am I right?

It would be great if one could fetch absolute urls with something like this

$backendUrl = urls()->admin->httpUrl
// or
$backendUrl = httpUrls()->admin

 

SOLVED:

Thank you @adrian – of course this HAD to be simpler:

urls()->httpAdmin;

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...