Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

452
Vistas
Can I serve an angular application in the same FastApi which have, of course, the Api?

I have an Api developed in FastApi framework. I have one Angular application that calls the FastApi. Due to several reasons, it would be great (network names, parameters, docker images, etc) if I could deploy the angular application in the FastApi as a simple web application. This way I could access the Api as "localhost" and the Api can be "private".

Is this possible?

thank you, José Cruz

over 4 years ago · Santiago Trujillo
2 Respuestas
Responde la pregunta

0

I don't know if it can help you but it worked for me.

I warn you that this is not a good practice but in the context I applied it solved my problem.

I have a small Angular application that login and authenticated redirection to FastAPI's Redoc and Swagger documentation.

I set up a directory with static files and put the angular build inside. In FastAPI I made an endpoint reading and serving the index.html file.

For the angular to see the files, I build Angular by passing the --base-href flag pointing to the mounted static directory.

The codes look like this:

project/
    static/
        index.html
        ... (files app angular)

    main.py

main.py

from fastapi import FastAPI
from fastapi.responses import HTMLResponse
from fastapi.staticfiles import StaticFiles


app = FastAPI()

app.mount("/static", StaticFiles(directory="static"), name="static")


@app.get('/')
def get_app_angular():

    with open('static/index.html', 'r') as file_index:
        html_content = file_index.read()
    return HTMLResponse(html_content, status_code=200)

Build APP Angular:

ng build --base-href static/ --prod

over 4 years ago · Santiago Trujillo Denunciar

0

No, it is not possible as far as I know. It would be like talking two different languages. With JSON files you may be able to share configurations, but not more.

Maybe going on the low level (both python and nodejs are written in C or C++), you could bind them, but you would get much more of an overhead to do this than to simply spawn two separate containers.

Also, separating API and frontend is a good practice, which allows you to perform changes/updates in a much simpler form and to scale one service in case of sudden peaks. In addition, the security is improved, as the two containers are virtually separated and secured by the containers. Breaking into one, would not necessarily compromise the second (I said would because it depends on what access information you store and permissions you give to the former).

over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda