codezero-be / laravel-localized-routes

⭐️ A convenient way to set up and use localized routes in a Laravel app.
MIT License
505 stars 46 forks source link

Unable to prepare route [sitemap.xml] for serialization. Another route has already been assigned name [es.sitemap]. #32

Closed lightbyte closed 3 years ago

lightbyte commented 4 years ago

Hi, in April 2020 I've made a project in Laravel 7 and this laravel-localized-routesv2.2.6. Now in October I installed in a new computer the development project and composer install downloaded the same version but it was changed, it started making error when trying artisan route:cache I have updated the libraries with composer update and now with version 2.3.2 has the same issue:

Unable to prepare route [sitemap.xml] for serialization. Another route has already been assigned name [es.sitemap].

The route:list shows the route for ES locale twice so when caching routes, the second one crashes with this error.

I have removed the fix for https://github.com/codezero-be/laravel-localized-routes/issues/28 in the file laravel-localized-routes/src/Macros/LocalizedRoutesMacro.php in line 31 and it worked.

My configuration file localized-routes.php has:

'supported-locales' => [
        'en' => env('APP_URL_EN'),
        'es' => env('APP_URL')
 ],
'omit_url_prefix_for_locale' => 'es',
'use_locale_middleware' => true,
'use_localizer' => false,

I don't know if I'm doing something wrong or maybe the fix didn't work for all cases.

ivanvermeyen commented 3 years ago

Hi and sorry for the long wait... Were you able to solve this issue? It's a bit weird that there are duplicate es.sitemap routes... If this is still a problem, let me know and I'll try to help you out.

lightbyte commented 3 years ago

Hi Ivan, I guess I did what its posted above, it was long time ago, but it's still working. Thanks for asking.

ivanvermeyen commented 3 years ago

Can you show me how you registered the sitemap route? I assume env('APP_URL_EN') and env('APP_URL') are domains? I'll try to reproduce this in a test then.

ivanvermeyen commented 3 years ago

Found the bug that most likely caused your issue. Will tag the fix soon. 👍

ivanvermeyen commented 3 years ago

Tagged and released in 2.5.0 🎉