• CORS woes on Heroku

    ,

    After spending the past 4 hours attempting to solve what boiled down to a rather simple problem, I figure I’d better blog about it to save someone else the time and effort.

    If you’ve been leveraging Passenger’s new –nginx-config-template command line option to add CORS headers to static assets served from a Rails app hosted on Heroku, and the CORS headers recently disappeared under mysterious circumstances… read on.

    I’ve been using the method described here to add CORS headers to custom fonts served from a Heroku-hosted Rails app that’s proxied by Nginx which handles serving static files. I recently updated to Rails 4.2.2 and suddenly, my custom fonts (.woff and .woff2 files) no longer had CORS headers on them.

    After the aforementioned hours spent scratching my head, I discovered that the latest version of the sprockets gem is generating asset digests that are 64 chars in length, where previously they had been 32. Nginx’s default regexp for identifying requests for static assets assumes the digest will be 32 chars long, like so:

    # Rails asset pipeline support.
    location ~ "^/assets/.+-[0-9a-f]{32}\..+" {
      error_page 490 = @static_asset;
      error_page 491 = @dynamic_request;
      recursive_error_pages on;</code>
    
      if (-f $request_filename) {
        return 490;
      }
      if (!-f $request_filename) {
        return 491;
      }
    }
    

    Changing the regexp to recognize digests that are 64 chars in length immediately solved the problem:

    location ~ "^/assets/.+-[0-9a-f]{64}\..+" {
       ...
    }
    

    I had to laugh after something so stupid and silly cost me a good chunk of my Saturday to debug. But at least it’s working now. My statically served custom fonts have the correct CORS headers and Chrome and Firefox are happy again.


Need help?

I’m an independent software developer available for consulting, contract work, or training. Contact me if you’re interested.


  • Quote of the Week: C.S. Lewis

    “Friendship is born at that moment when one person says to another: ‘What! You too? I thought I was the only one.’” —C.S. Lewis

  • Indieconf 2012: Build an Army of Products

    The intriguing title of Brennan Dunn’s talk was what convinced me to attend. I’ve never actually heard Brennan present before but I enjoy a good product talk. His presentation met and exceeded my expectations. It was well worth attending.

    I share the dream of many freelancers to one day stop trading time for money, ditch my consulting work, and focus 100% of my time on products that I’m passionate about. I’m not there yet, but for the past 5 years I’ve been moving in that direction with Teascript and a few topical blogs. I was looking forward to hearing a fellow freelancer share his story of going down this path.

    A year ago, Brennan had zero dollars in product income. He was consulting full time and “didn’t like it.” Not the work itself so much as the “hamster wheel.” He wanted off and decided to make it happen. A year later he is running a successful blog, selling an e-book, running a sustainable subscription-based SaaS application called Planscope, and producing a podcast.

    Over the course of the talk he explained (in as much detail as time allowed) the specifics of how he built up these products which have generated in the area of $35k for him in October alone. After learning this, I wanted to hear exactly how he accomplished such a feat. Fortunately, Brennan is generous with his information and explained as much as he could.

    Making the switch

    Ultimately, we control our own schedules. Nobody else has that privilege. The first step towards building successful products is changing our habits. It’s certainly possible to “moonlight” our way into a product business, but speaking from personal experience it’s much more difficult. There will always be tantalizingly billable work just waiting there for us to dive into.

    Speaking for myself, I’ve found it beneficial to ease into a product by gradually reducing the immediately billable work on my plate and replacing it with hours dedicated to my ideas. But as I said, this is a challenging approach (but less risky than other options).

    We’ve all heard these common excuses as to why we can’t switch our focus to products:

    • But… freelancing pays the bills!
    • But… products are hard!
    • But… my product is probably going to fail!
    • But… I don’t know how to sell!

    The truth is that unless we can get over these excuses, put ourselves out there, and execute on an idea… we’ll never know what could have been. Sure, failure will happen. Sure, it will be challenging. But is the dream worth the trouble? For me, it is.

    Don’t sell to consumers

    Brennan doesn’t believe in selling to consumers. “Only sell to businesses. Consumers don’t understand value.” He’s right. The products he has created target freelancers and consultants who are admittedly in a fuzzy area between consumer and business, but more often than not have a business mindset. The key part of this mindset that Brennan leverages is the willingness of a freelancer to pay a healthy price for a product that will ultimately bring a much greater return on investment.

    Another leverage point is the production of complimentary products that can be cross-sold. Once someone signs up for one of his newsletters, for example, he can eventually cross-sell them on his e-book. Once they’ve purchased the e-book, he can suggest they check out his SaaS application. This is a classic sales funnel, but it works. Acquiring new customers is hard and expensive. Selling to existing customers is easy and a big win.

    Brennan emphasized that his selling is low touch. In other words, he doesn’t do cold calling, send out massive spam campaigns, or hand out brochures on the street. His focus is on establishing a convincing marketing site that draws potential customers and turns them into qualified leads by giving them useful content. When this kind of marketing can be automated, our products can be sold with very little intervention. No more trading time for money.

    How to get started

    Pick something low risk. Start small. We shouldn’t have to ask friends or family for startup money. Bootstrapping a product from the ground up ensures the worst thing we’ll lose if the product fails is a few dozen hours of our time.

    Here are some questions you should be asking yourself:

    • What can you build that will sell?
    • What do people ask you about?
    • What does your network of people complain about?
    • Are you knowledgeable about any of this?
    • Can you research your way into a product?

    Brennan touched on pricing and suggested the following ranges:

    • books: $10 – $50
    • self-serve SaaS: $9 – $99
    • screencasts: $9 – $29

    Tiered pricing is also an option. The App Design Handbook was his example of a well-built web site offering various tiers of pricing for various packages (book, videos, an Xcode project, etc).

    Marketing strategies

    Establishing a customer funnel is crucial. Start by sending out a free weekly newsletter with useful content for your target market. This builds trust in your brand and helps turn potential customers into qualified leads who are familiar with your products. Use drip email campaigns to avoid having to come up with fresh content every week (something that could quickly become tiresome). Determine the LTV (Lifetime Total Value) of each of your customers so you know how much to spend on advertising.

    Give things away for free. Freebies present an extremely low barrier to entry and overcome trust issues because customers see that you know your stuff and are willing to give some of it away. Track everything. Data is king and gut assumptions can be costly. Determine CPC (Cost-per-Click), conversion rates, ROI, and so on. Split (A/B) test your landing pages, marketing emails, etc.

    Get people into your funnel by telling them how your product will solve their needs. Ultimately, nobody cares about your product. Everyone wants to know, “What’s in it for me?”

    Blog about your product, your career as a freelancer, your interests, your hobbies, etc. Reference your products within your blog posts. Include numbers and statistics in your posts. Numbers stand out and draw attention, building credibility for your brand.

    Specific technologies

    Brennan uses MailChimp and AWeber for drip email campaigns. He uses e-junkie to sell his books. In general, he leverages existing services to host his content instead of building things from scratch. This enables him to focus on creating top-notch content instead of fiddling with external concerns.

    He uses the following content pattern for his landing pages:

    pain => fix => offer => testimonials => overcoming objections => call-to-action

    By the end of Brennan’s presentation, my head was literally swimming with new ideas and things I wanted to try. Since Brennan was someone who had successfully jumped the chasm from freelancer to product owner, it was motivating to hear him explain how he got there. It convinced me more than ever that as freelancers, we are in a great position. We have the opportunity to productize our expertise and knowledge and transform our work in a fundamental way. Let’s not waste the opportunity.

    This post is one in a series from Indieconf 2012

  • Pomodoro Desktop for Mac review

  • Quote of the Week: Groucho Marx

    “Politics is the art of looking for trouble, finding it everywhere, diagnosing it incorrectly, and applying the wrong remedies.” –Groucho Marx