[Catalyst] Setting $c->req->{base}
Andy Grundman
andy at hybridized.org
Tue Sep 20 16:39:27 CEST 2005
Alessio Bragadini wrote:
> On Tue, 2005-09-20 at 09:14 -0400, Andy Grundman wrote:
>
>
>>I would recommend if you need to set base to something specific, that
>>you just do this in your App's begin() method:
>>
>>$c->req->base( 'http://whatever/' );
>
>
> I've tried this but didn't manage to make it work. That's why I asked
> for directions. Is begin called after base is pushed into the request
> object by Engine::*::Base?
Engine sets it up first, but then begin() will be called and your CUSTOM
value will overwrite the Engine value. I tested it on an app of mine
and it worked for me.
>>I don't think running the frontend on another port will make a
>>difference as the code only checks the address. HTTPS though, good
>>point. That will need to be handled as well.
>
>
> Seems to me you're tackling the specific issue without looking at the
> generic landscape. You may have all kinds of strange configurations that
> need to be handled when creating self-referencing URLs, https is an
> example but you may have webcal:// or some other http-based protocol or
> something we don't know yet. I thought that Catalyst was about
> flexibility, so I believe the right solution is to let users decide the
> base part of the address.
Well right now I'm really just concerned with getting the correct
hostname in base instead of http://localhost/ or http://127.0.0.1/. And
it turns out HTTPS cannot be auto-detected so you'll have to use
something like SetEnv HTTPS on in a second VirtualHost on the backend.
> I've sent you earlier today a patch that handles this and it's currently
> working fine on my server.
>
I think the begin method is much simpler than using $c->config->{base}
as in your patch.
-Andy
More information about the Catalyst
mailing list