Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8092763
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T20:21:23+00:00 2026-06-05T20:21:23+00:00

My config.ru is as follows: use Rack::Static, :urls => [/images], :root => public run

  • 0

My config.ru is as follows:

use Rack::Static, 
  :urls => ["/images"],
  :root => "public"

run lambda { |env|
  [
    200, 
    {
      'Content-Type'  => 'text/html', 
      'Cache-Control' => 'public, max-age=86400' 
    },
    File.open('public/index.html', File::RDONLY)
  ]
}

When I load it locally the website looks fine, but when I run it on Heroku I get the following error message in the browser console for the CSS files:

Resource interpreted as Stylesheet but transferred with MIME type text/html.

Any idea why I am getting these errors?

Example site: http://salus8.heroku.com.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T20:21:25+00:00Added an answer on June 5, 2026 at 8:21 pm

    Your app currently responds to requests in two different ways. Requests starting with /images are served by searching the /public/images folder and returning any file matching the request. Any other request is served by running the lambda block, which returns your index.html file with a content type of text/html.

    This applies to any other request, so when your page references a css file and the browser tries to fetch it, your app will return the index.html page with the HTML content type, hence the warning about MIME type.

    One way to fix this would be to add /css to the list of urls the Static middleware handles:

    use Rack::Static, 
      :urls => ["/images", "/css"],
      :root => "public"
    

    and put your css files in the public/css directory (as I write, it looks like you have already done this).

    This would solve your immediate problem, but you might have issues for example if you wanted to have more than one HTML page in the top directory.

    Another solution to achieve a static site that serves index.html to any requests with no path, which is what it looks like you’re trying to do here, could be to use the rack-rewrite gem and a Rack::File application. Add gem 'rack-rewrite' to your Gemfile, and then use a config.ru like this:

    require 'rack/rewrite'
    
    use Rack::Rewrite do
      rewrite "/", "/index.html"
    end
    
    run Rack::File.new("public")
    

    This will respond to all requests with the matching file (if it exists), and any requests that arrive with no path will get index.html. (Note that it won’t serve index.html for requests for subdirectories under the main directory).

    If you’re using Heroku’s Cedar stack, you could also look into faking a php app in order to get “real” static hosting with Apache.

    I don’t know why this would be working locally but not on Heroku, unless you’re just opening the files directly in the browser. Are you running a server locally (e.g. with rackup), or looking at the files direct?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

config.php put at the root level, this file will be included in any pages.
My db details in my Zend config file are as follows: resources.db.adapter = PDO_MYSQL
I would like to have an xml config file as follows: <?xml version=1.0 encoding=utf-8
I need to create a custom block in web config as follows: <MySettings> <add
I'm trying to use Ruby's SOAP support as follows: SERVICE_URL = 'https://...' ... def
I have the following PHP file: <?php use Symfony\Component\HttpKernel\Kernel; use Symfony\Component\Config\Loader\LoaderInterface; class AppKernel extends
In my web.config I have the Role Manager configured as follows: <roleManager enabled=true cacheRolesInCookie=true
I have done gem install pdfkit gem install wkhtmltopdf in application.rb added config.middleware.use PDFKit::Middleware,
I updated my web.config to support URL Rewriting but when I use it on
My problems is as follows. I use a SQL Server 2008 database. I don't

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.