question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Dummy data shown when API is unreachable

See original GitHub issue

How to reproduce the behaviour

Build the frontend: docker build -t doccano-frontend frontend

Launch: docker run --rm -it -p 3000:3000 doccano-frontend

Browsing to http://localhost:3000 shows the frontend, everything fine there, trying to login with fake credentials (username: 123, password: 123) works instead of failing with auth errors. So somewhere in the frontend container dummy data is stored and now sent to the client. The page at http://localhost:3000/projects shows a list of (dummy/testing) projects, where one would expect to see nothing (ie. auth errors)

As an example, this is the login call my browser tries:

curl 'http://localhost:3000/v1/auth-token' \
-XPOST \
-H 'Content-Type: application/json;charset=utf-8' \
--data-binary '{"username":"123","password":"123"}'

Which returns html…

When I point (hack) the nuxt code to some (dummy) url (http://localhost:12345/v1) to use as API, it does return Incorrect username or password when trying to login.

I haven’t looked at the code yet, figured I’d get this reported first.

Your Environment

  • Operating System: docker/mac
  • How did you install doccano (Heroku button etc): docker build

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
Hironsancommented, May 22, 2020

In early development, I have been developing frontend by using dummy API. It’s accessible from localhost:3000/v1. I used Nuxt’s serverMiddleware to implement the API. So If we remove the following lines, the API will be unreachable.

https://github.com/doccano/doccano/blob/a71fbd3e4ce576bfc08c0a5ca724388378200177/frontend/nuxt.config.js#L29-L31

Actually, it’s legacy code. I’m currently using Python’s backend API instead of the dummy API. It’s deletable.

0reactions
harmwcommented, May 23, 2020

the tryLogin() logic in frontend/components/organisms/auth/LoginForm.vue:

tryLogin() {
      if (this.validate()) {
        this.login({
          username: this.username,
          password: this.password
        })
          .then((result) => {
              this.$router.push('/projects')
          })
          .catch(() => {
            this.showError = true
          })
[..]

hypothesis: when the backend API returns a HTTP/400 vue triggers the catch(). However, since we’re talking to /v1 we get html returned, ie. a HTTP/200 which causes vue to move along with this.$router.push('/projects'). Meaning, we’re logged on and get to see the dummy data.

Would probably be sensible to just check if result is an object that holds a token-field, as that is how the API tells us everything is fine.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Cannot correctly use datas I have got from an API, errors
I'm new working with apis, I already made a post but I make a new one to clarify my problem. ... How can...
Read more >
10 Error Status Codes When Building APIs For The First Time ...
This status code means you haven't yet authenticated against the API. The API doesn't know who you are and it won't serve you....
Read more >
4 common API errors and how to test them - Assertible
API failures are inevitable; the important part is how quickly you can react. Here are 4 common API failures, and how you can...
Read more >
Top 3 Reasons for API Failures | Blazemeter by Perforce
You may or may not know what the other program does internally with your data and your request, but if everything works correctly,...
Read more >
Web API Error Handling: How To Make Debugging Easier
One of the first errors most of us encounter is the infamous HTTP 404 status code. It's a clear indicator to the consumer...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found