Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
hubertstruminski opened this issue Dec 3, 2019 · 2 comments

Comments

@hubertstruminski
Copy link

hubertstruminski commented Dec 3, 2019

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.

@alexandrtovmach
Copy link
Contributor

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

@Erickinhou
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants