Search code examples
apisymfonydeploymentsymfony4api-platform.com

Expose Symfony 4 application (API Platform) in production with FTP only


My application is composed of two repositories in my server :

  • www.example.com/htdocs/app (VueJS client)
  • www.example.com/htdocs/app__api (Symfony 4 with API Platform).

The deployment of VueJS client, it works. The deployment of API works too with all dependencies and his database. Besides, I install all SSH keys because I use LexikJWTAuthenticationBundle to connect to my application.

Connect my Client to API (production) with Axios :

So, if I understood correctly, when I connect my client to API with Axios, I use this url www.example.com/app__api in production.

Unfortunately, I have 404 error The requested URL www.example.com/app__api/api/token was not found on this server. when I want to login.

How expose correctly my API ?

So, I would like some examples to correctly expose an API. Maybe I need to write .htaccess or configure BASE_URL of my Symfony API. I don't know which way to go.


Solution

  • First of all, you need to configure your server. Apache or Nginx, But if you do not have an SFTP connection it is not possible.

    If we suppose you can get an SFTP access please see Symfony documentation how to configure web server.

    [https://symfony.com/doc/current/setup/web_server_configuration.html][1]

    In your API you can use halt check URL and if that URL is okay API is ok. Also, you can use swagger for knowing your APIs. And API platform uses bundle nelmio bundle for documentation URLs. You can read about it too.