Coder Social home page Coder Social logo

heroku / heroku-buildpack-static Goto Github PK

View Code? Open in Web Editor NEW
676.0 76.0 428.0 221 KB

[DEPRECATED] Heroku buildpack for handling static sites and single page web apps

License: MIT License

Shell 13.00% HTML 4.77% Ruby 79.77% Dockerfile 1.30% Makefile 1.16%

heroku-buildpack-static's Introduction

heroku-buildpack-static

NOTE: This buildpack is in an experimental OSS project.

This is a buildpack for handling static sites and single page web apps.

For a guide, read the Getting Started with Single Page Apps on Heroku.

WARNING: heroku-buildpack-static is deprecated

This buildpack is deprecated and is no longer being maintained. If you are using this project, you can transition over to NGINX via an NGINX buildpack. Use your project's existing configuration. To find the NGINX configuration generated by the heroku-buildpack-static you can run:

$ heroku run bash
~ $ bin/config/make-config
~ $ cat config/nginx.conf

These commands will output your current NGINX config generated from your static.json contents.

  • Write these contents to your local repo at config/nginx.conf.erb, commit them to git.
  • Replace path logic that previously used mruby with static logic.
  • Configure your app to use the NGINX buildpack via heroku buildpacks:add heroku-community/nginx.
  • Remove this buildpack via heroku buildpacks:remove heroku-community/static (or heroku buildpacks:remove https://github.com/heroku/heroku-buildpack-static).

Deprecation PRs

If you have tips or tricks for migrating off of this buildpack and want to add them to the instructions above please send a PR.

Features

  • serving static assets
  • gzip on by default
  • error/access logs support in heroku logs
  • custom configuration

Deploying

The static.json file is required to use this buildpack. This file handles all the configuration described below.

  1. Set the app to this buildpack: $ heroku buildpacks:set heroku-community/static.
  2. Deploy: $ git push heroku master

Configuration

You can configure different options for your static application by writing a static.json in the root folder of your application.

Root

This allows you to specify a different asset root for the directory of your application. For instance, if you're using ember-cli, it naturally builds a dist/ directory, so you might want to use that instead.

{
  "root": "dist/"
}

By default this is set to public_html/

Canonical Host

This allows you to perform 301 redirects to a specific hostname, which can be useful for redirecting www to non-www (or vice versa).

{
  "canonical_host": "www.example.com"
}

You can use environment variables as well:

{
  "canonical_host": "${HOST}"
}

Default Character Set

This allows you to specify a character set for your text assets (HTML, Javascript, CSS, and so on). For most apps, this should be the default value of "UTF-8", but you can override it by setting encoding:

{
    "encoding": "US-ASCII"
}

Clean URLs

For SEO purposes, you can drop the .html extension from URLs for say a blog site. This means users could go to /foo instead of /foo.html.

{
  "clean_urls": true
}

By default this is set to false.

Logging

You can disable the access log and change the severity level for the error log.

{
  "logging": {
    "access": false,
    "error": "warn"
  }
}

By default access is set to true and error is set to error.

The environment variable STATIC_DEBUG can be set, to override the error log level to error.

Custom Routes

You can define custom routes that combine to a single file. This allows you to preserve routing for a single page web application. The following operators are supported:

  • * supports a single path segment in the URL. In the configuration below, /baz.html would match but /bar/baz.html would not.
  • ** supports any length in the URL. In the configuration below, both /route/foo would work and /route/foo/bar/baz.
{
  "routes": {
    "/*.html": "index.html",
    "/route/**": "bar/baz.html"
  }
}
Browser history and asset files

When serving a single page app, it's useful to support wildcard URLs that serves the index.html file, while also continuing to serve JS and CSS files correctly. Route ordering allows you to do both:

{
  "routes": {
    "/assets/*": "/assets/",
    "/**": "index.html"
  }
}

Custom Redirects

With custom redirects, you can move pages to new routes but still preserve the old routes for SEO purposes. By default, we return a 301 status code, but you can specify the status code you want.

{
  "redirects": {
    "/old/gone/": {
      "url": "/",
      "status": 302
    }
  }
}
Interpolating Env Var Values

It's common to want to be able to test the frontend against various backends. The url key supports environment variable substitution using ${ENV_VAR_NAME}. For instance, if there was a staging and production Heroku app for your API, you could setup the config above like the following:

{
  "redirects": {
    "/old/gone/": {
      "url": "${NEW_SITE_DOMAIN}/new/here/"
    }
  }
}

Then using the config vars, you can point the frontend app to the appropriate backend. To match the original proxy setup:

$ heroku config:set NEW_SITE_DOMAIN="https://example.herokapp.com"

Custom Error Pages

You can replace the default nginx 404 and 500 error pages by defining the path to one in your config.

{
  "error_page": "errors/error.html"
}

HTTPS Only

You can redirect all HTTP requests to HTTPS.

{
  "https_only": true
}

Basic Authentication

You can enable Basic Authentication so all requests require authentication.

{
  "basic_auth": true
}

This will generate .htpasswd using environment variables BASIC_AUTH_USERNAME and BASIC_AUTH_PASSWORD if they are present. Otherwise it will use a standard .htpasswd file present in the app directory.

Passwords set via BASIC_AUTH_PASSWORD can be generated using OpenSSL or Apache Utils. For instance: openssl passwd -apr1.

Proxy Backends

For single page web applications like Ember, it's common to back the application with another app that's hosted on Heroku. The down side of separating out these two applications is that now you have to deal with CORS. To get around this (but at the cost of some latency) you can have the static buildpack proxy apps to your backend at a mountpoint. For instance, we can have all the api requests live at /api/ which actually are just requests to our API server.

{
  "proxies": {
    "/api/": {
      "origin": "https://hone-ember-todo-rails.herokuapp.com/"
    }
  }
}
Interpolating Env Var Values

It's common to want to be able to test the frontend against various backends. The origin key supports environment variable substitution using ${ENV_VAR_NAME}. For instance, if there was a staging and production Heroku app for your API, you could setup the config above like the following:

{
  "proxies": {
    "/api/": {
      "origin": "https://${API_APP_NAME}.herokuapp.com/"
    }
  }
}

Then using the config vars, you can point the frontend app to the appropriate backend. To match the original proxy setup:

$ heroku config:set API_APP_NAME="hone-ember-todo-rails"

Custom Headers

Using the headers key, you can set custom response headers. It uses the same operators for pathing as Custom Routes.

{
  "headers": {
    "/": {
      "Cache-Control": "no-store, no-cache"
    },
    "/assets/**": {
      "Cache-Control": "public, max-age=512000"
    },
    "/assets/webfonts/*": {
      "Access-Control-Allow-Origin": "*"
    }
  }
}

For example, to enable CORS for all resources, you just need to enable it for all routes like this:

{
  "headers": {
    "/**": {
      "Access-Control-Allow-Origin": "*"
    }
  }
}
Precedence

When there are header conflicts, the last header definition always wins. The headers do not get appended. For example,

{
  "headers": {
    "/**": {
      "X-Foo": "bar",
      "X-Bar": "baz"
    },
    "/foo": {
      "X-Foo": "foo"
    }
  }
}

when accessing /foo, X-Foo will have the value "foo" and X-Bar will not be present.

Route Ordering

  • HTTPS redirect
  • Root Files
  • Clean URLs
  • Proxies
  • Redirects
  • Custom Routes
  • 404

Procfile / multiple buildpacks

In case you have multiple buildpacks for the application you can ensure static rendering in Procfile with web: bin/boot.

Testing

For testing we use Docker to replicate Heroku locally. You'll need to have it setup locally. We're also using rspec for testing with Ruby. You'll need to have those setup and install those deps:

$ bundle install

To run the test suite just execute:

$ bundle exec rspec

Structure

To add a new test, add another example inside spec/simple_spec.rb or create a new file based off of spec/simple_spec.rb. All the example apps live in spec/fixtures.

When writing a test, BuildpackBuilder creates the docker container we need that represents the heroku cedar-14 stack. AppRunner.new takes the name of a fixture and mounts it in the container built by BuildpackBuilder to run tests against. The AppRunner instance provides convenience methods like get that just wrap net/http for analyzing the response.

Boot2docker

If you are running docker with boot2docker, the buildpack will automatically send tests to the right ip address. You need to forward the docker's port 3000 to the virtual machine's port though.

VBoxManage modifyvm "boot2docker-vm" --natpf1 "tcp-port3000,tcp,,3000,,3000";

Releasing new binaries

The steps buildpack maintainers need to perform when releasing new nginx binaries (either for a new stack or ngx_mruby version), are:

  1. Update the stacks list in Makefile and/or the ngx_mruby version in scripts/build_ngx_mruby.sh.
  2. Run make build to build all stacks or make build-heroku-NN to build just one stack.
  3. Ensure the AWS CLI is installed (eg brew install awscli).
  4. Authenticate with the relevant AWS account (typically by setting the environment variables from PCSK).
  5. Run make sync (or if using a custom S3 bucket, S3_BUCKET=... make sync).
  6. Update bin/compile to reference the new stacks and/or nginx version URLs.
  7. Open a PR with the changes from (1) and (6).

heroku-buildpack-static's People

Contributors

ankon avatar biw avatar budnik avatar dependabot[bot] avatar dhaulagiri avatar edmorley avatar fortybillion avatar hone avatar joshwlewis avatar jsoref avatar nicolasleger avatar ojacobson avatar randallagordon avatar root-io avatar schneems avatar svc-scm avatar tevanoff avatar tiii avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

heroku-buildpack-static's Issues

Default headers do not specify encoding

STR:

$ curl -XHEAD -v 'http://grimoire.ca/dev/builds'

Expected:

< Content-Type: text/html; charset=UTF-8

Actual:

< Content-Type: text/html

This causes non-ASCII characters in the document to come out, uh, badly. Defaulting to UTF-8 is probably sane; we might want to make it configurable ("encoding": "UTF-8" perhaps?)

403 Error on 404 Page

I have recently encountered a very odd error while utilizing this buildpack. Here is my static.json (all urls changed to hide proprietary info):

{
  "root": "dist/",
  "error_page": "404.html",
  "clean_urls": true,
  "proxies": {
    "/gift-cards": {
      "origin": "https://www.test.com/test"
    }
  },
  "redirects": {
    "/": {
      "url": "/test"
    }
  },
  "https_only": true
}

Here is my directory structure:

screen shot 2017-02-01 at 6 21 27 pm

When trying to access a page that 404s on Heroku, I get the follow error in the logs:

app[web.1]: 2017/02/02 02:13:16 [error] 23#0: *6 directory index of "./dist/" is forbidden, client: 10.146.110.248, server: , request: "GET / HTTP/1.1", host: "www.test.com"

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

Hello, thanks for this buildpack, it works nicely with my webpack app. The only problem I see is the following warning in the developer console:

"Resource interpreted as Stylesheet but transferred with MIME type text/html: https://<app>.herokuapp.com/style/style.css"
Is this something I need to address in static.json? My static.json looks like this:

{
  "root": "/",
  "https_only": true,
  "clean_urls": false,
  "routes": {
   "/**": "app/index.html"
 }
}

Thanks for any input!

Best
-act

Support multiple domains

This buildpack does not seem to support multiple domains. I only looked at the README.
Could multiple domains with a per-domain root folder support be added?

Support HTTP/2

The version of nginx in the buildpack (1.9.7) should support HTTP/2 natively.

HTTP/2 offers big advantages for static sites and SPAs.

Can you consider adding HTTP/2 support to the nginx config?

(p.s. I did give it an attempt before posting this)

Set higher default client_max_body_size

I know there is a pull request to make this configurable: #42

But in the meantime, can you hardcode client_max_body_size to something reasonably bigger than 1MB ?

I know there is a lot of use cases out there, but the default value is like really low... I'd say make it 50MB.

It does not work for me

I tried to build https://github.com/gamesover/address-book-pwc/blob/master/static.json ,but build logs how no info.

-----> Static HTML app detected
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
-----> Installed directory to /app/bin
-----> Discovering process types
       Procfile declares types     -> (none)
       Default types for buildpack -> web
-----> Compressing...
       Done: 1.1M
-----> Launching...
       Released v17
       https://address-book-pwc-2017.herokuapp.com/ deployed to Heroku

Current, my only buildpack is this one(yes, I may add ruby and nodejs later). Not sure why it does not work. You may try https://address-book-pwc-2017.herokuapp.com/

Thanks for your advice.

Cache deploy?

The deploy is very slow. Is there any way to create a cache like buildpack-php does?

Thanks!

Add helpful error message for empty/invalid static.json file

Spotted in the wild:

2016-12-08T22:54:05.813905+00:00 app[web.1]: /usr/lib/ruby/1.9.1/json/common.rb:148:in `initialize': A JSON text must at least contain two octets! (JSON::ParserError)

This is the error users receive at runtime if they have a static.json present but it's empty. I'm wondering how you'd feel about trying to catch this at the build stage with a more helpful warning, potentially covering other invalid json cases as well. If you have a preference I can try to put together a PR.

MIME types for fonts

Please add mime types for woff, woff2, eot and ttf. I'm not 100% sure, but according to this, those are font/woff, font/woff2, application/vnd.ms-fontobject and font/ttf respectively.

Clean URLs won't clean if there's a directory

Over at test double, I have:

join.html
/join
  developer.html

And the clean_urls option enabled. Unfortunately, since /join is a directory, hitting the path /join yields an nginx not authorized error. Anything we can do about this?

autoindex on

Thought's on supporting autoindex on? Initially perhaps just toggleable for all routes, but perhaps eventually on a per route basis?

I'd be happy to submit a PR.

Allow Custom Nginx Configurations

Some web server configurations are too complex to be supported through the static.json interface. By allowing the use of a custom nginx.conf, we can support more complex needs without having to build every edge case into the buildpack.

The Heroku PHP buildpack supports custom NGINX configurations using include files and command line arguments.

Another solution could be adding pre and post-compile hooks like the Heroku Python buildpack. This would allow a user to overwrite the nginx.conf.erb template as needed.

domain specific headers / configuration

Hi,

Could you please add the possibility to define domain specific headers ?
It would be cool if you could use environment variable substitution like so:

{
    "headers": {
        "/": { // default
            "Set-Cookie": "locale=es"
        },
        "${ENV_VAR_TO_SOME_FRENCH_SUBDOMAIN}/": {
            "Set-Cookie": "locale=fr"
        },
       "${ENV_VAR_TO_SOME_ENGLISH_SUBDOMAIN}/": {
            "Set-Cookie": "locale=en"
        }
}

It would be even nicer to have the possibility of defining domain specific configurations.

If i knew ruby, i would like to do it myself, but unfortunately i do not :-(

thank you very much,
Tom.

Prevent certain files in root from being served

Sorry if this can be accomplished with the current config options already, but I can't figure it out.

I currently have the root option set to my dist/ directory, which contains all of the static assets I need to serve. However, I'd like to prevent any *.js.map files from being served. Is that possible?

I attempted to use the redirect option to redirect /**/*.map to / and status 404 but that did not seem to do anything.

Parameter proxying granularity

This build pack makes it incredibly easy to proxy through to an API service. We love this feature at Canvas! ❤️ To use it in production however, we need more control over how we can construct the proxy URL.

We want to proxy:

GET
https://usecanvas.com/{team}/{title}/{uuid}.md

===>

GET
Accept: text/plain
https://api.usecanvas.com/canvases/{uuid}

or

GET
https://usecanvas.com/{team}/{title}/{uuid}.json

===>

GET
Accept: application/json
https://api.usecanvas.com/canvases/{uuid}

This allows us to serve a rendered canvas through an Ember app and by simply appending .md to the URL get a Markdown representation – proxied to the API.

We understand if this is too specific to Canvas but in that case would love to be able to inject some kind of middleware. Maybe some additional nginx config like this:

# From https://gist.github.com/chids/874201

# Copy the accept header to a variable
set $acceptHeader $http_accept;

# Does the request end in xml or json?
if ($uri ~ ^(.*)\.(xml|json)$) {
  # Create a new accept header...
  set $acceptHeader "application/$2";
  # ...and remove the extension from the path
  rewrite ^(.*)\.(xml|json)$ $1 last;
}

# Set the Accept header for the proxied resource
proxy_set_header Accept $acceptHeader;

# ...continue with normal proxy conf, host and path mapping etc

Proxy API

Hi!
In my static.js I set:

    {
    "root": "build/",
    "routes": {
      "/**": "index.html"
    },
    "proxies": {
        "/v2/": {
          "origin": "https://api.mydomain.com/"
        }
    }
  }

My request are like this:

   axios.post('/v2/login_check', { _username, _password }).then(res => res.data)

My request are not going to api.mydomain.com/v2/login_check, they are going to myapp.herokuapp.com/v2/login_chek, for exemple. My static.js is right?

Thank's guys!

Add Proxy Header Configuration Options

I'd like to be able to provide more configuration options to proxies.

Allowing users to configure options such as proxy_pass_request_headers or proxy_set_header would allow them to provide custom headers such as X-Key-Inflection used by projects such as Olive Branch: https://github.com/vigetlabs/olive_branch.

Big fan of this project btw, thanks for this!

Confusing error for invalid `static.json`

If static.json is invalid, the error is obtuse:

2017/04/25 02:25:34 [error] 29#0: *7 mrb_run failed: return 500 HTTP status code to client: error: /app/bin/config/lib/ngx_mruby/headers.rb:7: invalid json (ArgumentError), client: 10.93.229.188, server: , request: "GET /address HTTP/1.1", host: "APP-client.herokuapp.com"

It would be amazing to wrap that JSON parsing with a rescue and a output a clear error message when it's invalid. Maybe even parse it during compile and fail the build when invalid.

Basic HTTP Auth

It would be great to have the option to easily add basic http auth for semi-private sites!

Proxy logic adds slashes

The code handling the proxies configuration always adds a slash to the end of the origin. This is quite confusing, and can potentially lead to hard-to-debug errors depending on the origin server handles double slashes in URLs.

How to set client_max_body_size ?

How to set nginx configuration for this?
client_max_body_size 2M;

I often get Entity too large 413, when uploading image with file size > 1MB

502 errors

First of all, this looks really promising, thanks for your work on this.

We've been using this other buildpack successfully for a few of our older Ember projects and we've tried this out for about 2 months on a new project, but had to switch back.

The reason is that we were occasionally seeing 502 errors. We have our Ember app proxying to an API app and we believe that when Heroku changes the API dyno's IP nginx fails to re-resolve it. We've solved this with the other buildpack by storing the API domain as a variable and configuring a DNS resolver for nginx, something like:

<% if ENV["API_URL"] %>
  # Required, without a resolver directive and without storing the
  # domain in a variable, nginx will never re-resolve it, and won't be
  # able to connect when our dyno's ip dynamically changes.
  resolver 8.8.8.8 8.8.4.4 208.67.222.222 valid=5s;
  <% $backend = ENV["API_URL"] %>
  set $backend <%= $backend %>;

  location <%= ENV["API_PREFIX_PATH"] || "/api/" %> {
    proxy_pass $backend;
  }
<% end %>

Any ideas on solving the problem in a different way or adding support for it into the buildpack would be awesome.

Preserve GET parameters for redirects

I am trying to implement a redirect in my static.json, which seems to work as expected in most cases:

{
  "redirects": {
    "/old-login": {
      "url": "${NEW_SITE_URL}/new-login",
      "status": 302
    }
  }
}

However, it seems to strip all my GET parameters, which I would need in some cases. For example,
https://old-site.com/old-login?token=12345 redirects to https://new-site.com/new-login, and that breaks my flow.
Is there anyways to pass all the GET parameters to the redirected URL? I guess this would be doable by allowing regex in the redirects, but hopefully there's a simpler (and already available) way of doing this?

Invalid Host header

I am receiving the error message Invalid Host header from the server.

  1. I added the buildpacks:
$ heroku buildpacks:clear
$ heroku buildpacks:add heroku/nodejs
$ heroku buildpacks:add https://github.com/heroku/heroku-buildpack-static
  1. Pushed a valid static.json file
  2. Deployed my app

But instead of running the bin/boot process of the static buildpack, it seems that npm start starts the node process from the nodejs buildpack. When I remove the startscript from the package.json I get an Application Error from Heroku. How can I ensure that the static buildpack feels responsible for the app?

Support multiple apps per repo

Hi,

Is there currently any way to serve multiple apps in the same repo with heroku-buildpack-static ?

We serve multiple apps (an API and two React SPAs) from one repo using Heroku Multi Procfile buildpack. Right now the SPAs are served using serve but we'd like to move to static serving with https redirection support.

Thanks !

Feature Request: Wildcards in Redirects

Support wildcards in redirects, like:

{
  "redirects": {
    "/foo/**": "/"
  }
}

So that /foo/bar/baz will redirect to /bar/baz and /foo/asdf will redirect to /asdf.

Add Basic Auth Configuration

Though it could be interesting to support basic auth in specific location blocks, generally I think a single, server level configuration would suffice for most use cases.

Proposed implementation:

{
  "basic_auth": true
}

If true, looks for htpasswd file in project root.

Double Redirect - https to http with trailing slashes

Hey folks 👋

I'm using this static build pack with https_only turned on. Our app is predominantly a set of index.html files in folders so that we can access them like this: https://example.com/post/a-lovely-blog-post/ which would then serve /post/a-lovely-blog-post/index.html as expected.

The problem is that when you navigate to https://example.com/post/a-lovely-blog-post (no trailing slash) it then redirects you to http://example.com/post/a-lovely-blog-post/ (trailing slash but http) which then redirects you again to https://example.com/post/a-lovely-blog-post/ (trailing slash and https) because of https_only

I can't quite track exactly where that intermediate 301 redirect is coming from (the one that adds the trailing slash but removes https). If someone could point me in the right direction I would be happy to introduce a PR to fix it 👍

Socket Proxy

I cannot seem to configure a proxy to a websocket endpoint without the websocket request timing out and opting for polling. It seems as though you need these options in config for nginx to proxy it properly:

  location ~* \.io {
      proxy_set_header X-Real-IP $remote_addr;
      proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
      proxy_set_header Host $http_host;
      proxy_set_header X-NginX-Proxy true;

      proxy_pass http://localhost:3000;
      proxy_redirect off;

      proxy_http_version 1.1;
      proxy_set_header Upgrade $http_upgrade;
      proxy_set_header Connection "upgrade";
    }

Any ideas on how I can make this happen?

Content Security Policy Headers

Hey, I'm trying to set my CSP in static.json. I'm using Heroku pipelines for a frontend client and backend api (both hosted on heroku), and I don't want to use *.herokuapp.com for requests from my frontend apps to my backend apps.

Is it possible to inject env vars into the Content-Security-Policy header? Or maybe there's a better way to do what I'm trying to do? Thanks!

Proxying combined with https only ends up redirecting to the proxy url

We ran into some unexpected (at least to me 😀 ) snags when enabling https_only: true in combination with a proxy config. As discussed at emberjs/website#2850, the behavior I was seeing was that a browser would be redirected to the raw proxy url instead of upgraded to https for the proxy url.

i.e. expected behavior:

http://www.emberjs.com/api-new -> https://www.emberjs.com/api-new

actual behavior:

http://www.emberjs.com/api-new -> https://<raw-proxy-url>/

Proxy configuration without path rewrite

Is it possible to have a proxy configuration so that requests to

http://my.herokuapp.com/api/first/endpoint

will be proxied to

https://rest.herokuapp.com/api/first/endpoint

without loosing the api portion of the URL?

I tried something like

  "proxies": {
    "/api/": {
      "origin": "https://rest.herokuapp.com"
    }
  },

in my static.json (with all kinds of possible combinations and variations like appending api to the origin URI or adding or removing slashes).

I think the problem is related to #29, nginx is trying to normalize the URL if it detects origin to be a URI. By appending a slash to the hostname, this buildpack always produces a URI configuration, no matter if there is a path or not.

Can't deploy static assets

I get the following error when I attempt to run $ heroku static:deploy:

TypeError: Path must be a string. Received undefined
    at assertPath (path.js:7:11)
    at Object.resolve (path.js:1146:7)
    at setopts (/Users/ewanvalentine/.local/share/heroku/plugins/node_modules/glob/common.js:97:21)
    at new GlobSync (/Users/ewanvalentine/.local/share/heroku/plugins/node_modules/glob/sync.js:40:3)
    at Function.globSync [as sync] (/Users/ewanvalentine/.local/share/heroku/plugins/node_modules/glob/sync.js:26:10)
    at /Users/ewanvalentine/.local/share/heroku/plugins/node_modules/archiver-utils/file.js:62:17
    at /Users/ewanvalentine/.local/share/heroku/plugins/node_modules/archiver-utils/file.js:30:19
    at Array.forEach (native)
    at processPatterns (/Users/ewanvalentine/.local/share/heroku/plugins/node_modules/archiver-utils/file.js:24:23)
    at Object.file.expand (/Users/ewanvalentine/.local/share/heroku/plugins/node_modules/archiver-utils/file.js:60:17)
    at Object.file.expandMapping (/Users/ewanvalentine/.local/share/heroku/plugins/node_modules/archiver-utils/file.js:94:8)
    at /Users/ewanvalentine/.local/share/heroku/plugins/node_modules/archiver-utils/file.js:159:19
    at arrayMap (/Users/ewanvalentine/.local/share/heroku/plugins/node_modules/lodash/lodash.js:660:23)
    at Function.map (/Users/ewanvalentine/.local/share/heroku/plugins/node_modules/lodash/lodash.js:9571:14)
    at interceptor (/Users/ewanvalentine/.local/share/heroku/plugins/node_modules/lodash/lodash.js:16970:35)
    at thru (/Users/ewanvalentine/.local/share/heroku/plugins/node_modules/lodash/lodash.js:8812:14) 'error'
(node:9671) DeprecationWarning: Archiver.bulk() deprecated since 0.21.0

I'm using the node build pack, and this build pack. I'm attempting to deploy a static html file, js and a css file, in a subdirectory dist. Here's the static.json...

{
  "root": "public",
  "clean_urls": false,
  "routes": {
    "/**": "index.html"
  }
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.