bencodezen / vue-enterprise-boilerplate

An ever-evolving, very opinionated architecture and dev environment for new Vue SPA projects using Vue CLI.
7.77k stars 1.32k forks source link

Sockjs keeps sending request to local middleware API #152

Closed biyootiful closed 4 years ago

biyootiful commented 5 years ago

Hello,

First, I'd like to thank you guys for this awesome boilerplate :)

I have not found any related issues in this repo so I'm writing to submit one.

We have a node middleware locally running on port 4545 that communicates to db. When running the client application with API_BASE_URL var, I noticed that sockjs keeps sending get requests to the middleware (presumably). For instance,

190524/163146.835, (1558715506835:Xxxxx-MacBook-Pro.local:3062:jw2aasrx:10059) [response] http://localhost:4545: get /sockjs-node/237/jahszuog/websocket {} 404 (1ms)

And of course, it returns 404 since there's no route for /sockjs-node. It does not seem to break anything, but I'd like to get to the bottom of this so I can get rid of these error messages or let the MW dev know what to do.

I'm not an expert with sockjs library, any help or guidance would be greatly appreciated!

chrisvfritz commented 5 years ago

Could you provide the value you're using for API_BASE_URL and how the middleware is being registered. The contents of vue.config.js could also be helpful. 🙂

biyootiful commented 5 years ago

Sure thing!

API_BASE_URL=localhost:4545
//vue.config.js
module.exports = {
  // Same as https://github.com/chrisvfritz/vue-enterprise-boilerplate/blob/master/vue.config.js
    ...
  },
  // Configure Webpack's dev server.
  // https://cli.vuejs.org/guide/cli-service.html
  // Only used for mock API
  devServer: {
    ...(process.env.API_BASE_URL
      ? // Proxy API endpoints to the production base URL.
        { proxy: { '/': { target: process.env.API_BASE_URL } } }
      : // Proxy API endpoints a local mock API.
        { before: require('./tests/mock-api') }),
  },
}

*NOTE: Currently, we don't use API_BASE_URL since the API is on different domain, so I don't think the dev server configuration is utilized. We use VUE_APP_... to expose the API base url and use custom util to wrap axios instances with the base url value.

However, this sockjs-node issue still existed when I used to run API_BASE_URL=value yarn dev in the script like the documentation suggests (when we haven't deployed the middleware). So I'd be inclined to think it has something to do with middleware dependencies. I can't really reveal every dependency due to NDA, but wondering if there's a known issue with sockjs and hapi framework .. or would sockjs complain if middleware used nodemon (but my understanding of nodemon is that it only detects file changes and restarts)?

If this issue is too specific to us, please close it. But it'd be really nice to not seeing the error message every second in my terminal 😅

chrisvfritz commented 4 years ago

I'm going to close this as a niche mystery case for now, as I'm still unable to reproduce it. Happy to reopen if more people report they're affected.