Skip to content

Grunt Serve Watch keeps triggering injection and livereload when there is an ajax call or js error #650

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

Closed
nelsonomuto opened this issue Oct 21, 2014 · 9 comments

Comments

@nelsonomuto
Copy link

Grunt Serve Watch keeps triggering injection and livereload when there is an ajax call or js error.

It seems like the page is reloading the script tags.

@kingcody
Copy link
Member

@nelsonomuto sorry for the delayed response, but I was wondering if you've made any changes to your grunt watch configuration? If so would you mind posting your gruntfile in a gist?

@nelsonomuto
Copy link
Author

No problem, thanks for the reply.

Actually I found the issue was a server redirect. In line 21 of the
server/routes.js file there is a redirect to index.html for unknown
assests. In my angular client I had configured some states with
non-existent paths for the templateUrl. Instead of returning a 404 when
said states were activated, the app was responding back with the
index.html, thus all the scripts were being reloaded and it was producing
the funky behavior that made it seem like a livereload.

Disabling the configured redirect made it behave normal, I simply got a
404, however that redirect is important for html5 location mode, which I
need, so I will go ahead and close this issue.

I had some views with templates pointing at non existent paths and the
express app
On Oct 25, 2014 5:56 PM, "Cody Mize" [email protected] wrote:

@nelsonomuto https://github.com/nelsonomuto sorry for the delayed
response, but I was wondering if you've made any changes to your grunt
watch configuration? If so would you mind posting your gruntfile in a gist
https://gist.github.com/?


Reply to this email directly or view it on GitHub
#650 (comment)
.

@nelsonomuto
Copy link
Author

To summarize if you attempt to load a file that does not exist but whose path is in any defined asset, then the response is the index.html. Which is confusing because this reloads and executes the scripts therein if you initially where loading said resource as a view or it was the source of a script tag or link to a stylesheet.

For example this is my known asset that the route is using:
// All undefined asset or api routes should return a 404 app.route('/:url(api|auth|components|app|bower_components|assets|containerapps)/*') .get(errors[404]);

So if in my client I attempt to load /containerapps/non-existentFile.js it will not return a 404 because this is a "defined" asset. Instead it will return index.html because in route.js there exists in line 21 this code:
// All other routes should redirect to the index.html app.route('/*') .get(function(req, res) { res.sendfile(app.get('appPath') + '/index.html'); });

@kingcody
Copy link
Member

@nelsonomuto thats odd, I actually get a 404 when accessing anything listed in api|auth|components|app|bower_components|assets that doesn't exist.

@nelsonomuto
Copy link
Author

Can you show ur route.js file
On Oct 26, 2014 4:17 AM, "Cody Mize" [email protected] wrote:

@nelsonomuto https://github.com/nelsonomuto thats odd, I actually get a
404 when accessing anything listed in
api|auth|components|app|bower_components|assets that doesn't exist.


Reply to this email directly or view it on GitHub
#650 (comment)
.

@kingcody
Copy link
Member

Sure thing

module.exports = function(app) {

  // Insert routes below
  app.use('/api/things', require('./api/thing'));
  app.use('/api/users', require('./api/user'));

  app.use('/auth', require('./auth'));

  // All undefined asset or api routes should return a 404
  app.route('/:url(api|auth|components|app|bower_components|assets)/*')
   .get(errors[404]);

  // All other routes should redirect to the index.html
  app.route('/*')
    .get(function(req, res) {
      res.sendFile(app.get('appPath') + '/index.html', {
        root: config.root
      });
    });
};

@kingcody
Copy link
Member

I'd like to point out that I'm using the newest express version which changes the sendFile syntax from previous versions. In case you were wondering about that.

@nelsonomuto
Copy link
Author

Nelson Omuto would like to connect on LinkedIn. How would you like to respond?

Accept: http://www.linkedin.com/blink?simpleRedirect=3gQcjoQd3AUcj8Rdz0UcjgQejkZh4BKrSBQonhFtCVF9CAOtktTsAhyfnBBiShBsC5EsOoVclZMu6lvtCVFfmJB9D9Bp6VFrmlObnhMpmdzoiRybmtSrCBvrmRLoORIrmkZpSVFqSdxsDgCpnhFtCV9pSlipn9Mfm4Cq3gJrSUNpP0TcSAJqTxBp6dJbjRBfP9SbSkLrmZzbCVFp6lHrCBIbDtTtOYLeDdMt7hE&msgID=I8454768885_1&markAsRead=

View Nelson Omuto's profile: http://www.linkedin.com/blink?simpleRedirect=ej5vs7xBnTpKqjRHpipOpmhKqmRBsyRQs6lzoS4JoyRDtCVFnSRJrScJr6RBfmtKqmJzon9Q9DpMrzRQ9CwQbmZKcmsMdPdFbmJUpmhzriQZpjYOtyZBbSRLoOVKqmhBqSVFr2VTtTsLbPFMt7hE&msgID=I8454768885_1&markAsRead=

You are receiving Reminder emails for pending invitations. Unsubscribe here: http://www.linkedin.com/blink?simpleRedirect=rmZzhj8BoDlEt6BDhj8BumNMpn8Md2kTc38Sd3kNbmcTp35ypzcRpj8SdzcQdzsPe6cUpz8NoPpAoCoOcPlyozoOomdBdC4Jc30McPcQdzgJqk8O9nBIs6lOfmNFomRB9z0Sc30OfmhF9zgQcjoQd3AUcj8Rdz0UcjgQejkZp6BD9zANnT1UplZSrCAZqSkCoDlPrDkJpyRzoClJnSRJrScJr6RBfmtKqmJzon9Q9CZLpPRQ9CwQbmZKcmsMdPdFbmJUpmhzriQZpjYOtyZBbSRLoOVKqmhBqSVFr2VTtTsLbPFMt7hE&msgID=I8454768885_1&markAsRead=

You received an invitation to connect. LinkedIn will use your email address to make suggestions to our members in features like People You May Know. Unsubscribe here: http://www.linkedin.com/blink?simpleRedirect=q3gJrSUNpP0TcSAJqTxBp6dJbjRAqmkCgl59kB1bm5cRi4dnlBhvrjwOi4FjomNatSdAhl1kr4dMdBoPszwRdAJvsmBejQRflk9EjQNWdzBCoj1okDhacmBpj7tfsBEJlAFctm57q49xjmsMc4hqhkgTlQgRtTB2t6lvsSJymll3e5ETgAdLiApmrRlegAxWckINqD9CqPxFp4N6dDdPr31RuCVgekBbrRl1gk5Tr6hke4FqsTFVikthgjRAqmZI9zANnT1UplZSrCAZqSkCkjoPp4l7q5p6sCR6kk4ZrClHrRhAqmQCrDlIfngCq3gJrSUNpP0TcSAJqTxBp6dJbjRBfP9SbSkLrmZzbCVFp6lHrCBIbDtTtOYLeDdMt7hE&msgID=I8454768885_1&markAsRead= Learn why we included this at the following link: http://www.linkedin.com/blink?simpleRedirect=0Ue3sQfmh9pmNzqnhOoioVclZMu6lvtCVFfmJB9CNOlmlzqnpOpldOpmRLt7dRoPRx9CwQbmZKcmsMdPdFbmJUpmhzriQZpjYOtyZBbSRLoOVKqmhBqSVFr2VTtTsLbPFMt7hE&msgID=I8454768885_1&markAsRead=
© 2014, LinkedIn Corporation. 2029 Stierlin Ct. Mountain View, CA 94043, USA

@angular-fullstack angular-fullstack locked and limited conversation to collaborators Dec 2, 2014
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants