Spring-Boot-Blog-REST-API icon indicating copy to clipboard operation
Spring-Boot-Blog-REST-API copied to clipboard

401 response on homepage

Open arvindpdmn opened this issue 2 years ago • 3 comments

Describe the bug Cloned the repo and followed the readme but I get 401 error. Screenshot is attached.

To Reproduce Steps to reproduce the behavior:

  1. Follow the Readme.
  2. Update MySQL username and password in both _application.properties and application.yml files (in folder src/main/resources).
  3. In application.yml, replace "blogapi-db:3306" with "localhost:3306"
  4. In pom.xml, update lombok version to 1.18.22 to solve a build issue.
  5. Run mvn spring-boot:run
  6. Access http://localhost:8080 on browser.

Expected behavior Homepage should be seen without errors.

Screenshots image

Desktop (please complete the following information):

  • OS: Windows10
  • Browser: Brave
  • Version: [Version 1.51.118 Chromium: 113.0.5672.126 (Official Build) (64-bit)]

arvindpdmn avatar May 28 '23 17:05 arvindpdmn

Welcome @arvindpdmn to Spring-Boot-Blog-REST-API community! Thanks so much for creating your first issue :)

github-actions[bot] avatar May 28 '23 17:05 github-actions[bot]

@arvindpdmn You have to check it on Postman.

ShubhamUpadhyay-7 avatar May 20 '24 11:05 ShubhamUpadhyay-7

  • The repository uses Java 11 (and you should to). That would solve the Lombok issue without needing to change what is existing in the POM file.
  • Remember that a REST API is a back-end only. Meaning text and in this case JSON is the only thing that is received by the client from the server. Download applications like Postman or Insomnia that allow you to easily run APIs. For sign up: you would choose POST and enter http://localhost:8080/api/auth/signup then for the body choose JSON and enter the example JSON in the README.
  • To use most of the APIs you need to sign in. So with the user you just created, use the sign in API. Make sure to save the accessToken (it always starts with "ey" since it's a JWT) as it is the Authorization/Auth that needs to be inserted as the Bearer token in future requests so the API knows you are signed in.

Aaron98990 avatar Oct 08 '25 01:10 Aaron98990