-
Notifications
You must be signed in to change notification settings - Fork 264
Fix URL generation #592
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
Fix URL generation #592
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -361,4 +361,43 @@ public function test_responsable_with_invalid_key(): void | |
| $page['props']['resource'] | ||
| ); | ||
| } | ||
|
|
||
| public function test_the_page_url_is_prefixed_with_the_proxy_prefix(): void | ||
| { | ||
| if (version_compare(app()->version(), '7', '<')) { | ||
| $this->markTestSkipped('This test requires Laravel 7 or higher.'); | ||
| } | ||
|
|
||
| Request::setTrustedProxies(['1.2.3.4'], Request::HEADER_X_FORWARDED_PREFIX); | ||
|
|
||
| $request = Request::create('/user/123', 'GET'); | ||
| $request->server->set('REMOTE_ADDR', '1.2.3.4'); | ||
| $request->headers->set('X_FORWARDED_PREFIX', '/sub/directory'); | ||
|
|
||
| $user = ['name' => 'Jonathan']; | ||
| $response = new Response('User/Edit', ['user' => $user], 'app', '123'); | ||
| $response = $response->toResponse($request); | ||
| $view = $response->getOriginalContent(); | ||
| $page = $view->getData()['page']; | ||
|
|
||
| $this->assertInstanceOf(BaseResponse::class, $response); | ||
| $this->assertInstanceOf(View::class, $view); | ||
|
|
||
| $this->assertSame('/sub/directory/user/123', $page['url']); | ||
| } | ||
|
|
||
| public function test_the_page_url_doesnt_double_up(): void | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This test previously failed. I took it from #360.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The main issue could be hosting Laravel in a subdirectory, which Laravel explicitly doesn't support. That being said, the previous combination of |
||
| { | ||
| $request = Request::create('/subpath/product/123', 'GET', [], [], [], [ | ||
| 'SCRIPT_FILENAME' => '/project/public/index.php', | ||
| 'SCRIPT_NAME' => '/subpath/index.php', | ||
| ]); | ||
| $request->headers->add(['X-Inertia' => 'true']); | ||
|
|
||
| $response = new Response('Product/Show', []); | ||
| $response = $response->toResponse($request); | ||
| $page = $response->getData(); | ||
|
|
||
| $this->assertSame('/subpath/product/123', $page->url); | ||
| } | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note that this test passed prior to the changes. It exists to ensure no regression on the issue that #333 was solving.