react-twitter-auth icon indicating copy to clipboard operation
react-twitter-auth copied to clipboard

405 Method Not Allowed: SyntaxError: Unexpected token < in JSON at position 0

Open hubertstruminski opened this issue 5 years ago • 2 comments

Can you tell me how handle with this error ? I get 405 method not allowed.

react-twitter-auth-component.js:359 POST http://divelog.com.s3-website-us-east-1.amazonaws.com/callback 405 (Method Not Allowed) LogIn.js:65 SyntaxError: Unexpected token < in JSON at position 0

@PostMapping("/signin/twitter") public String loginWithTwitter(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { ........ } @PostMapping("/callback") public void loginWithTwitterCallback(HttpServletRequest request, HttpServletResponse response) ...... Cookie cookie = new Cookie("twitterJwtToken", jwtToken); cookie.setSecure(false); cookie.setMaxAge(60 * 60 * 24); cookie.setPath("/"); response.addCookie(cookie); }

I also tried change type of request to GET and later POST but error is the same and can you tell me how can I use this component on localhost ? I try do it, but I get cors error at client side. I use React JS. I have added cors at server side in Spring Boot.

hubertstruminski avatar Dec 03 '19 18:12 hubertstruminski

Try this package instead https://www.npmjs.com/package/react-twitter-login

alexandrtovmach avatar Dec 11 '19 13:12 alexandrtovmach

Same to me, I think this error occurs because the package expects a json on the return of the backend and you are sending an HTML, that's why the error is Unexpected token < in JSON, the "<" character is the initial tag of your HTML.

Erickinhou avatar Feb 17 '22 00:02 Erickinhou