Question

I'm trying to serve a dynamically generated html page with Erlang Cowboy, but it comes up as text in Firefox 14.0.1.

Here's the doctype and initial header tags copied from browser page source:

<DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="Content-type" content="text/html;charset="UTF-8"><title>Welcome!</title>
<link href="css/bootstrap.css" rel="stylesheet">
yada yada

If I leave off the doctype, it displays as intended.

Bootstrap Scaffolding (http://twitter.github.com/bootstrap/scaffolding.html) calls for the html doctype.

I'm not sure if this is a problem with my html or my Cowboy configuration.

Here's the relevant portion of Dispatch in _app.erl:

   {['...'], cowboy_http_static,
       [ {directory, {priv_dir, cw, []}},
           {mimetypes, [  {<<".css">>, [<<"text/css">>]} ]}

Can someone please show the me error of my ways?

Many thanks,

LRP

Was it helpful?

Solution

I use cowboy_static to serve a DOCTYPE html and it serves fine, with the correct mimetype. Missing the exclamation mark: "!DOCTYPE" instead of "DOCTYPE"

<!DOCTYPE html>

See http://www.w3schools.com/tags/tag_doctype.asp

Edit: Firefox and Chrome accepts <DOCTYPE html> as well. So the issue is most probably the Mimetype.

OTHER TIPS

Try this

{['...'], cowboy_http_static,
   [ {directory, {priv_dir, cw, []}},
       {mimetypes, [{<<".css">>, [<<"text/css">>]},
                    {<<".html">>, [<<"text/html">>]}]}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top