Skip to content
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 404 Error when making ajax Requests in projects hosted on a path in the domain #1544

Merged
merged 1 commit into from Sep 12, 2020

Conversation

coolsam726
Copy link
Contributor

This PR fixes the issue of having 404 errors when the asset_url setting is set to a sub-path, especially for projects NOT hosted on the root domain.

Fixes #1535 , #1482

@calebporzio calebporzio merged commit cf9bc8a into livewire:master Sep 12, 2020
@calebporzio
Copy link
Collaborator

Thanks @coolsam726 for looking into this so deeply.

Here are my thoughts.

I merged this, but changed the code significantly on master: 21c9c32

Take a look.

I don't think it's a good idea to look at the "asset_url" for reformatting the "referer".

My reasoning is that it'd be kind of a hidden behavior: That livewire helps Laravel understand a route match by using the "asset_url" because MOST of the time the asset_url is the same as the sub-path URL.

For example, for you, you are setting env('APP_URL') to it in the config, which means it's a full URL. However, the examples show just paths or even urls without schemes (like hey.com/something).

In these cases, your parsing would break down and cause odities.

I think for now it's better to just attempt to get the route from the referer, if we can't, just use the current route.

All that means is that you won't get a very specific feature that most people don't use anyways.

I'm going to tag this tomorrow, and I imagine all your problems will go away.

Thanks!

@coolsam726
Copy link
Contributor Author

Thanks @coolsam726 for looking into this so deeply.

Here are my thoughts.

I merged this, but changed the code significantly on master: 21c9c32

Take a look.

I don't think it's a good idea to look at the "asset_url" for reformatting the "referer".

My reasoning is that it'd be kind of a hidden behavior: That livewire helps Laravel understand a route match by using the "asset_url" because MOST of the time the asset_url is the same as the sub-path URL.

For example, for you, you are setting env('APP_URL') to it in the config, which means it's a full URL. However, the examples show just paths or even urls without schemes (like hey.com/something).

In these cases, your parsing would break down and cause odities.

I think for now it's better to just attempt to get the route from the referer, if we can't, just use the current route.

All that means is that you won't get a very specific feature that most people don't use anyways.

I'm going to tag this tomorrow, and I imagine all your problems will go away.

Thanks!
I have looked at your commit. This is just brilliant. Thank you.

@jamesbhatta
Copy link

Thank you @coolsam726 for your pull request. It saved my project.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

404 Error when hosting the project on a subpath
3 participants