Permalink
Browse files

Forward requests to node

  • Loading branch information...
adri committed Aug 5, 2017
1 parent fb71f57 commit c7c9c5dcadd776913b27da4da3534ea2d16ea87e
Showing with 14 additions and 20 deletions.
  1. +1 −1 assets/lib/initApollo.js
  2. +2 −2 bin/heroku_compile_assets
  3. +3 −0 config/config.exs
  4. +4 −1 config/prod.exs
  5. +1 −1 lib/picape/application.ex
  6. +1 −15 lib/picape_web/router.ex
  7. +1 −0 mix.exs
  8. +1 −0 mix.lock
@@ -14,7 +14,7 @@ function create(initialState) {
ssrMode: !process.browser, // Disables forceFetch on the server (so queries are only run once)
dataIdFromObject: o => o.id,
networkInterface: createNetworkInterface({
uri: 'http://localhost:4000/graphql', // Server URL (must be absolute)
uri: '/graphql', // Server URL (must be absolute)
opts: {
// Additional fetch() options like `credentials` or `headers`
credentials: 'same-origin',
@@ -8,11 +8,11 @@
# See phoenix_static_buildpack.config for a little more context.
cd $assets_dir
MIX_ENV=prod ./node_modules/webpack/bin/webpack.js --progress --color;
yarn build
cd ../
mix "${phoenix_ex}.digest"
# We don't need the asset files after compile. This helps keep
# the heroku slug size down.
rm -rf $assets_dir
#rm -rf $assets_dir
@@ -22,6 +22,9 @@ config :logger, :console,
format: "$time $metadata[$level] $message\n",
metadata: [:request_id]
config :reverse_proxy,
upstreams: %{"localhost:4001" => ["http://localhost:4001"]}
# Import environment specific config. This must remain at the bottom
# of this file so it overrides the configuration defined above.
import_config "#{Mix.env}.exs"
@@ -18,7 +18,10 @@ config :picape, PicapeWeb.Endpoint,
url: [scheme: "https", host: System.get_env("HOST"), port: 443],
force_ssl: [rewrite_on: [:x_forwarded_proto]],
cache_static_manifest: "priv/static/cache_manifest.json",
secret_key_base: System.get_env("SECRET_KEY_BASE")
secret_key_base: System.get_env("SECRET_KEY_BASE"),
watchers: [
bash: ["../bin/spawn_execute.sh", "node", "node_modules/next/dist/bin/next-start", "-p", "4001",
cd: Path.expand("../assets", __DIR__)]]
config :picape, Picape.Repo,
adapter: Ecto.Adapters.Postgres,
@@ -17,7 +17,7 @@ defmodule Picape.Application do
supervisor(Absinthe.Subscription, [PicapeWeb.Endpoint]),
# Start your own worker by calling: Picape.Worker.start_link(arg1, arg2, arg3)
# worker(Picape.Worker, [arg1, arg2, arg3]),
supervisor(ConCache, [[ttl: :timer.hours(5)], [name: :supermarket]])
supervisor(ConCache, [[ttl: :timer.hours(5)], [name: :supermarket]]),
]
# See http://elixir-lang.org/docs/stable/elixir/Supervisor.html
@@ -9,26 +9,12 @@ defmodule PicapeWeb.Router do
plug :put_secure_browser_headers
end
pipeline :api do
plug :accepts, ["json"]
end
# scope "/", PicapeWeb do
# pipe_through :browser # Use the default browser stack
# end
# Other scopes may use custom stacks.
scope "/api", PicapeWeb do
pipe_through :api
get "/", PageController, :index
end
forward "/graphql", Absinthe.Plug, schema: PicapeWeb.Graphql.Schema
forward "/graphiql", Absinthe.Plug.GraphiQL,
schema: PicapeWeb.Graphql.Schema,
socket: PicapeWeb.UserSocket,
interface: :simple
forward "/", ReverseProxy, upstream: ["localhost:4001"]
if Mix.env == :dev do
scope "/dev" do
@@ -44,6 +44,7 @@ defmodule Picape.Mixfile do
{:gettext, "~> 0.11"},
{:cowboy, "~> 1.0"},
{:swoosh, "~> 0.7"},
{:reverse_proxy, "~> 0.3.1"},
{:poison, "~> 2.0"},
{:httpoison, "~> 0.12"},
{:credo, "~> 0.7", only: [:dev, :test]},
@@ -39,6 +39,7 @@
"poolboy": {:hex, :poolboy, "1.5.1", "6b46163901cfd0a1b43d692657ed9d7e599853b3b21b95ae5ae0a777cf9b6ca8", [:rebar], [], "hexpm"},
"postgrex": {:hex, :postgrex, "0.13.3", "c277cfb2a9c5034d445a722494c13359e361d344ef6f25d604c2353185682bfc", [:mix], [{:connection, "~> 1.0", [hex: :connection, repo: "hexpm", optional: false]}, {:db_connection, "~> 1.1", [hex: :db_connection, repo: "hexpm", optional: false]}, {:decimal, "~> 1.0", [hex: :decimal, repo: "hexpm", optional: false]}], "hexpm"},
"ranch": {:hex, :ranch, "1.3.2", "e4965a144dc9fbe70e5c077c65e73c57165416a901bd02ea899cfd95aa890986", [:rebar3], [], "hexpm"},
"reverse_proxy": {:hex, :reverse_proxy, "0.3.1", "8aef287c5ea321c4af4a87945129a3278d4dee43b238e2497a45115b9254810c", [], [{:cowboy, "~> 1.0", [hex: :cowboy, repo: "hexpm", optional: false]}, {:httpoison, "~> 0.9", [hex: :httpoison, repo: "hexpm", optional: false]}, {:plug, "~> 1.2", [hex: :plug, repo: "hexpm", optional: false]}], "hexpm"},
"slime": {:hex, :slime, "0.16.0", "4f9c677ca37b2817cd10422ecb42c524fe904d3630acf242b81dfe189900272a", [:mix], [], "hexpm"},
"ssl_verify_fun": {:hex, :ssl_verify_fun, "1.1.1", "28a4d65b7f59893bc2c7de786dec1e1555bd742d336043fe644ae956c3497fbe", [:make, :rebar], [], "hexpm"},
"swoosh": {:hex, :swoosh, "0.8.1", "1d169e4b377095feba9b4456dac446155b11cde57f3a612c37035f073104f6f8", [:mix], [{:cowboy, "~> 1.0", [hex: :cowboy, repo: "hexpm", optional: true]}, {:gen_smtp, "~> 0.11", [hex: :gen_smtp, repo: "hexpm", optional: true]}, {:hackney, "~> 1.6", [hex: :hackney, repo: "hexpm", optional: false]}, {:mime, "~> 1.1", [hex: :mime, repo: "hexpm", optional: false]}, {:plug, "~> 1.1", [hex: :plug, repo: "hexpm", optional: true]}, {:poison, "~> 1.5 or ~> 2.0 or ~> 3.0", [hex: :poison, repo: "hexpm", optional: false]}], "hexpm"},

0 comments on commit c7c9c5d

Please sign in to comment.