IT-Academy-BCN / ita-profiles-frontend

2 stars 0 forks source link

[FE] Use the backend endpoint to list roles #48

Closed jordimorillo closed 7 months ago

jordimorillo commented 8 months ago

Dado que actualmente el listado de filtros por rol está hardcodeado Y queremos obtenerlo del backend Para ello vamos a consultar la documentación de backend y utilizaremos el endpoint que nos devuelve el listado de roles para obtener un json y pintar el listado en la vista de listado de alumnos abierta. Sabremos que ésto se cumple cuando veamos que en producción obtiene el contenido del filtro de roles mediante una petición al back.

Dar-ya218 commented 7 months ago

Hi, it seems we're having a net::ERR_CONNECTION_REFUSED error when trying to connect to the server at http://127.0.0.1:8000/student/list/for-home. I believe this error usually indicates that the server is not accepting the connection.

jordimorillo commented 7 months ago

Try this address: https://itaperfils.eurecatacademy.org/api/v1/student/list/for-home

Dar-ya218 commented 7 months ago

Thank you for the correct link. However, I'm still encountering an error: Access to XMLHttpRequest at 'https://itaperfils.eurecatacademy.org/api/v1/student/list/for-home' from origin 'http://localhost:4000' has been blocked by CORS policy: The 'Access-Control-Allow-Origin' header contains multiple values ', ', but only one is allowed.

danaketh commented 7 months ago

You'll have to fix your CORS setup. I suppose you're using some sort of proxy like Nginx to serve the website? Change Access-Control-Allow-Origin header from *, * to * for a quick fix. However if this is a production environment, you should spend time to configure it properly. In this case it should contain https://itaperfils.eurecatacademy.org (which may require you to play a bit more with the configuration due to the app being passed through proxy).

Dar-ya218 commented 7 months ago

I have managed to connect with the new URL https://itaperfils.eurecatacademy.org/api/v1/specialization/list that I found in the documentation and which has finally worked. So now the 'roles' field is correctly connected with the backend and prints correctly.