-1

I have a new symfony 4.4 project with api platform installed (via composer require api) and reactJs with Webpack Encore. I can't display Api platform (127.0.0.1:8000/api) view when i have the

@Route("/{reactRouting}", name="home", defaults={"reactRouting": null})

inside my DefaultController.php :

class DefaultController extends AbstractController {

/**
 * @Route("/{reactRouting}", name="home", defaults={"reactRouting": null})
 */
public function index()
{
    return $this->render('default/index.html.twig');
}

But when i remove it i can access /api but i can't access my route from react (/login etc).

  • 1
    There was a [similar issue](https://stackoverflow.com/questions/64710720) yesterday, but in this case route priorities aren't available in 4.x. You can still [define it in config files](https://stackoverflow.com/questions/48494301#48970410) so it's the last route loaded and has the least priority, to give a chance to other routes to match first. – msg Nov 08 '20 at 00:10
  • I need a controller to be linked to the path '/api' in routes.yaml but there is no controller for api platform. I noticed that the routes for my entity was available (/api/exemple/1) and show me the view. But i can't get the main view that is /api. – maverick lafont Nov 08 '20 at 00:40
  • 2
    There's no need to link it to a controller, take a look in `config/routes/api_platform.yaml`. It should just be loaded last. – msg Nov 08 '20 at 01:07

1 Answers1

1

I fixed my problem, I needed to exclude /api intro requirements in @Route, see the link here : https://stackoverflow.com/a/49475504/12094795