Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Bad requests for static content should return 404 #286

Closed
polidore opened this Issue · 14 comments

8 participants

Benjamin Polidore Owen Barnes freezy Paul Jensen Morgan Craft SocketStream Christian Sterzl Roman Minkin
Benjamin Polidore

I understand the idea of returning the main client for any path due to HTML5 client side paths, but if a HTTP request asks for a .html, .png, .jpg, it would be better to return a 404 if there is no such content in the static directory. Today it returns the client for bad urls to static content, and this can yield odd results.

In sum, RESTful path? return the client.
Request for an asset (*.html, *.jpg, *.png, *.gif) that doesn't exist? 404.

bp

Owen Barnes

I agree. Good point.

If you fancy having a crack at this I'd gladly merge it in; otherwise I'll add it to the TODO list.

Basically we need to change the logic here:

https://github.com/socketstream/socketstream/blob/master/src/http/index.coffee#L92

so that we parse the URL request, isolate the extension, and pass every request to the static handler (by calling next()) if it is for a .jpeg, .png, etc.

Benjamin Polidore
Benjamin Polidore polidore referenced this issue in polidore/ss-angular
Closed

Templates in sub folders? #18

freezy

This still seems to be happening. In my case, the browser keeps on reloading all the Javascripts, finally leading to a crash.

Debugging this kind of behavior is very hard and I nearly abandoned SS because of it. Thanks to @polidore who came up with a solution in the referenced issue above.

Paul Jensen paulbjensen was assigned
Paul Jensen
Owner

I will fix this before 0.3.11 is released.

Morgan Craft

Ran into an issue adding twitter bootstrap and the css files attempt to load fonts/ as static content and socketstream has a meltdown. I believe this is of a similar issue? I'm willing to dive in and see if I can't sort this out. @paulbjensen do you have existing work on this that I should look at? Or just jump in?

SocketStream
Christian Sterzl

Have you tried to copy the fonts Folder from Bootstrap into the client static folder?

Paul Jensen
Owner

I can also recommend loading Bootstrap via a CDN as a way to work around this issue:

@import url('http://netdna.bootstrapcdn.com/bootstrap/3.0.1/css/bootstrap.min.css')
@import url('http://netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.css')

We'll need to take a look at this file: https://github.com/socketstream/socketstream/blob/master/lib/http/index.js#L96

I'll be at home in an hour to have a look at this.

Roman Minkin
Owner

Actually problem in the original *.css files. I'm using font-awesome and it works just fine. All you need to do is:
1. Move fonts folder into client/static/fonts
2. Move all the *.css file into client/css/
2. Replace all the entries of ../fonts/ in *.css with /fonts/

@font-face {
  font-family: 'FontAwesome';
  src: url('/fonts/fontawesome-webfont.eot?v=4.0.2');
  src: url('/fonts/fontawesome-webfont.eot?v=4.0.2#iefix') format('embedded-opentype'), url('/fonts/fontawesome-webfont.woff?v=4.0.2') format('woff'), url('/fonts/fontawesome-webfont.ttf?v=4.0.2') format('truetype'), url('/fonts/fontawesome-webfont.svg?v=4.0.2#fontawesomeregular') format('svg');
  font-weight: normal;
  font-style: normal;
}
Paul Jensen
Owner

Thanks @RomanMinkin.

We'll need to find a way to allow SocketStream http routing to be configurable so that HTTP requests for files can return a 404 instead of the html for the client, at the moment 200's are returned, and the parser for that file breaks because it's getting back HTML content where it expects something else.

On a side note, something to consider for 0.4 will be how to support using client-side modules/components in such a way that we could install them via either npm or bower or component.io, and then load them in our app without need to move files to different locations. It's a tough cookie, but I think that cracking this would be great.

Christian Sterzl

+1 for that cookie.

Morgan Craft

@RomanMinkin thanks for the input, that fixed my problem. looks like I was trying to link my fonts within the css folder, not sure why I didn't try the static directory. thnkx.

Paul Jensen
Owner

This is now fixed by PR #419. It will be part of release 0.3.11

Benjamin Polidore
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.