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

How to set plugin route to load before dynamic route? #407

Open
leekung opened this issue May 8, 2024 · 1 comment
Open

How to set plugin route to load before dynamic route? #407

leekung opened this issue May 8, 2024 · 1 comment

Comments

@leekung
Copy link
Contributor

leekung commented May 8, 2024

I have dynamic route in config/route.php like this (it load vue + vue router)

Route::disableDefaultRoute();
Route::get('[{path:.+}]', [IndexController::class, 'index'])->name('public.index');

then I add webman/push plugin that has its own route file but got error when run

FastRoute\BadRouteException: Static route "/plugin/webman/push/push.js" is shadowed by previously defined variable route "(.+)" for method "GET" in /Users/mactat/Work/Gambling/source/vendor/nikic/fast-route/src/DataGenerator/RegexBasedAbstract.php:95
Stack trace:
#0 /Users/mactat/Work/Gambling/source/vendor/nikic/fast-route/src/DataGenerator/RegexBasedAbstract.php(30): FastRoute\DataGenerator\RegexBasedAbstract->addStaticRoute('GET', Array, Array)
#1 /Users/mactat/Work/Gambling/source/vendor/nikic/fast-route/src/RouteCollector.php(44): FastRoute\DataGenerator\RegexBasedAbstract->addRoute('GET', Array, Array)
#2 /Users/mactat/Work/Gambling/source/vendor/workerman/webman-framework/src/Route.php(382): FastRoute\RouteCollector->addRoute('GET', '/plugin/webman/...', Array)

I think if I can set the plugin route to load first it will work but dont know how to set it
or any other solution to fix this

@yisibugua
Copy link

yisibugua commented Oct 11, 2024

/**
 * 推送js客户端文件
 */
Route::get('/plugin/webman/push/push.js', function (Request $request) {
    return response()->file(base_path().'/vendor/webman/push/src/push.js');
});

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

No branches or pull requests

2 participants