Angular example using a nodejs backend
Hi, fusionauth provides an application example using Angular. This example contains a frontend part and a middleware with nodejs.
Is it possible to use only Angular without a middleware? And only pass JWT token to backend?
dan last edited by
Sure, store the access token in a secure cookie.
We don't have any examples of that with Angular, but here's a diagram of the flow: https://fusionauth.io/learn/expert-advice/authentication/spa/oauth-authorization-code-grant-jwts-refresh-tokens-cookies/
You'll still have to have some kind of backend because server side code is required to exchange the authorization code for the access token, as above. But you can then have the JWT be stored as a cookie and sent to APIs without further interaction with the backend server.
The alternative is to use the implicit grant, documented here: https://fusionauth.io/docs/v1/tech/oauth/overview#example-implicit-grant
But we strongly advise against that since it exposes your access tokens to XSS attacks.