mirror of
https://github.com/archtechx/tenancy.git
synced 2025-12-12 05:14:05 +00:00
fix origin identification: parse hostname when full URL is used
This commit is contained in:
parent
d8af9b4b43
commit
91295f01e2
2 changed files with 11 additions and 1 deletions
|
|
@ -10,6 +10,10 @@ class InitializeTenancyByOriginHeader extends InitializeTenancyByDomainOrSubdoma
|
|||
{
|
||||
public function getDomain(Request $request): string
|
||||
{
|
||||
return $request->header('Origin', '');
|
||||
if ($origin = $request->header('Origin', '')) {
|
||||
return parse_url($origin, PHP_URL_HOST) ?? $origin;
|
||||
}
|
||||
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -36,6 +36,12 @@ test('origin identification works', function () {
|
|||
->withHeader('Origin', 'foo.localhost')
|
||||
->post('home')
|
||||
->assertSee($tenant->id);
|
||||
|
||||
// Test with a full URL - not just a hostname
|
||||
pest()
|
||||
->withHeader('Origin', 'https://foo.localhost')
|
||||
->post('home')
|
||||
->assertSee($tenant->id);
|
||||
});
|
||||
|
||||
test('tenant routes are not accessible on central domains while using origin identification', function () {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue