Notes on simple authentication feature of Cyclic.sh Node Express App. Hosting service

Note: This post is a details-post for the post: Learning web app development through free online tutorials – Organized Notes and Log, https://raviswdev.blogspot.com/2024/03/learning-web-app-development-through.html .

Interesting auth feature in cyclic: https://docs.cyclic.sh/concepts/auth

https://en.wikipedia.org/wiki/Basic_access_authentication

The entire auth mechanism in cyclic app can be enabled/disabled through a single radio button. But if the /api/posts route is specified as needing auth, it seems that all the api requests - get, post, put and delete - are forced to be authenticated. So the current version of the React app. (which does not send any authentication headers in its api requests) fails to get data at initial load time itself (api get request) and puts up the message, "Get Data error. Details: Request failed with status code 401".

Axios seems to have a way to specify common headers (like Auth) for all requests: https://github.com/axios/axios#global-axios-defaults


Comments

Archive