I’d say so, yes. So, both the frontend and Symfony are available on the very same protocol (HTTP), host and port (80), hence no CORS issues to be expected at all. In fact, I’d not include the localhost part when calling the API, but just use /api for which the browser will use the same protocol, host and port as the calling Vue.js application. So, the same thing will then work from, say, 127.0.0.1 or any true domain name.
Though things work, there’s still a tight mapping between Nginx and the PHP container, like for root /var/www/public (which I guess is how Nginx determines a value for $document_root), and for the mapping to index.php. You may want to look into that some day.
Also, you can remove any ports setting for the PHP container, as that is now only accessed through/by Nginx.
It’s just like you’ve said. I can call the API from the frontend with just /api/user/login. I thank you really much, you’ve helped me a lot. I learned a lot.
The only thing which makes some trouble is, that Vue won’t connect to the WebSocket.
Is that just the WebSocket for the development server? Or a WebSocket for Symfony? I’ve no idea how to set up the latter. For non-FastCGI it would be something like:
Actually, to make that work, the Symfony container would need to map /some/request/path to /some/server/document-root/index.php/some/request/path, which is now done by Nginx. So, yet another reason to make that container smart enough to do its own mappings.
Oh, as we’ve seen that the Vue.js container needs this to be localhost, the above will bite you if you ever access Nginx using something else than localhost, in which case $host will be set to whatever is used then. So, you’d better hardcode proxy_set_header Host localhost; for the WebSocket configuration too.