Bad requests for static content should return 404 #286

Closed
polidore opened this Issue Aug 22, 2012 · 14 comments

Projects

None yet

8 participants

@polidore
Contributor

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

owenb commented Aug 23, 2012

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.

Contributor

i'll take a look at it monday.

On Thu, Aug 23, 2012 at 8:04 AM, Owen Barnes notifications@github.comwrote:

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.


Reply to this email directly or view it on GitHubhttps://github.com/socketstream/socketstream/issues/286#issuecomment-7967423.

@polidore polidore referenced this issue in polidore/ss-angular Jul 22, 2013
Closed

Templates in sub folders? #18

freezy commented Jul 22, 2013

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.

@paulbjensen paulbjensen was assigned Oct 23, 2013
Contributor

I will fix this before 0.3.11 is released.

Contributor
mgan59 commented Nov 27, 2013

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?

Contributor

Hi,

I haven't had a chance yet, please jump in. Thanks.

Regards,

Paul Jensen

On Wednesday, November 27, 2013, Morgan Craft wrote:

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 https://github.com/paulbjensen do you have
existing work on this that I should look at? Or just jump in?


Reply to this email directly or view it on GitHubhttps://github.com/socketstream/socketstream/issues/286#issuecomment-29388465
.

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

Contributor

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.

Contributor

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/
  3. 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;
}
Contributor

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.

+1 for that cookie.

Contributor
mgan59 commented Dec 2, 2013

@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.

Contributor

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

Contributor

nice work!

On Tue, Dec 31, 2013 at 7:19 AM, Paul Jensen notifications@github.comwrote:

Closed #286 #286.


Reply to this email directly or view it on GitHubhttps://github.com/socketstream/socketstream/issues/286
.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment