tighten / ziggy

Use your Laravel routes in JavaScript.
MIT License
3.93k stars 250 forks source link

Site is in subdirectory, but route doesn't include it #108

Closed Josh865 closed 6 years ago

Josh865 commented 6 years ago

First, thanks for the great package--it's made setting up my app's AJAX calls much easier.

I've run into an issue that I can't solve, and I'm not sure if I'm missing something or if it's a bug.

My site is in a subdirectory named buildings, so it's base URL is something like www.mysite.com/buildings.

In Laravel, I have an admin routes group that looks something like this:

Route::group(['prefix' => 'admin'], function () {
    Route::get('/sources', 'SourceController@index')->name('source.index');
}

So, the full URL for the above route is https://www.mysite.com/buildings/admin/sources.

When I use Ziggy to generate that route for an AJAX call, it sends the request to https://www.mysite.com/admin/sources, omitting the /buildings. The code for the AJAX call in question (which is in a .vue file) is:

fetchSources: function() {
    axios.get(route('source.index'))
    .then((response) => {
        this.sources = response.data;
    })
}

On my local machine where my site is not in a subdirectory, everything works fine, leading me to think that the issue is arising in connection with my production site being in a subdirectory.

degerstrom commented 6 years ago

I reported this in #102, my temporary fix is to downgrade to version 0.4

Which reminds me that I owe @DanielCoulbourne some feedback.

DanielCoulbourne commented 6 years ago

Duplicate of #110