@@ -267,33 +267,76 @@ if System.get_env("IMAGES_MODE") == "S3" do
267
267
path: System . get_env ( "S3_PATH" , "images/" )
268
268
end
269
269
270
- if config_env ( ) == :prod do
271
- # The secret key base is used to sign/encrypt cookies and other secrets.
272
- # A default value is used in config/dev.exs and config/test.exs but you
273
- # want to use a different value for prod and you most likely don't want
274
- # to check this value into version control, so we use an environment
275
- # variable instead.
276
- secret_key_base =
277
- get_env_or_raise_with_message . (
278
- "SECRET_KEY_BASE" ,
279
- "You can generate one by calling: mix phx.gen.secret"
280
- )
281
-
282
- host = get_env_or_raise . ( "PHX_HOST" )
283
- port = get_env_cast_integer_with_default . ( "PORT" , "4000" )
284
-
285
- config :epochtalk_server , EpochtalkServerWeb.Endpoint ,
286
- url: [ host: host , port: 443 , scheme: "https" ] ,
287
- http: [
288
- # Enable IPv6 and bind on all interfaces.
289
- # Set it to {0, 0, 0, 0, 0, 0, 0, 1} for local network only access.
290
- # See the documentation on https://hexdocs.pm/plug_cowboy/Plug.Cowboy.html
291
- # for details about using IPv6 vs IPv4 and loopback vs public addresses.
292
- ip: { 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 } ,
293
- port: port
294
- ] ,
295
- secret_key_base: secret_key_base
270
+ ## Configure endpoint
271
+ base_endpoint_config = [
272
+ url: [ host: "localhost" ] ,
273
+ render_errors: [
274
+ formats: [ json: EpochtalkServerWeb.Controllers.ErrorJSON ] ,
275
+ layout: false
276
+ ] ,
277
+ pubsub_server: EpochtalkServer.PubSub ,
278
+ live_view: [ signing_salt: "2Ay27BWv" ] ,
279
+ secret_key_base: get_env_or_raise_with_message . (
280
+ "SECRET_KEY_BASE" ,
281
+ """
282
+ You can generate one by calling: mix phx.gen.secret
283
+ If running in dev mode, add it to .env
284
+ """
285
+ )
286
+ ]
287
+ # Secret key base is used to sign/encrypt cookies and other secrets.
288
+ endpoint_secret_key_base =
289
+
290
+ endpoint_config = case config_env ( ) do
291
+ :dev ->
292
+ # For development, we disable any cache and enable
293
+ # debugging and code reloading.
294
+ #
295
+ # The watchers configuration can be used to run external
296
+ # watchers to your application. For example, we use it
297
+ # with esbuild to bundle .js and .css sources.
298
+ [
299
+ # Binding to loopback ipv4 address prevents access from other machines.
300
+ # Change to `ip: {0, 0, 0, 0}` to allow access from other machines.
301
+ http: [ ip: { 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 } , port: 4000 ] ,
302
+ check_origin: false ,
303
+ code_reloader: true ,
304
+ debug_errors: false ,
305
+ watchers: [ ]
306
+ ]
307
+ :test ->
308
+ # We don't run a server during test. If one is required,
309
+ # you can enable the server option below.
310
+ [
311
+ http: [ ip: { 127 , 0 , 0 , 1 } , port: 4002 ] ,
312
+ server: false
313
+ ]
314
+ :prod ->
315
+ host = get_env_or_raise . ( "PHX_HOST" )
316
+ port = get_env_cast_integer_with_default . ( "PORT" , "4000" )
317
+ [
318
+ # Include the path to a cache manifest
319
+ # containing the digested version of static files. This
320
+ # manifest is generated by the `mix phx.digest` task,
321
+ # which you should run after static files are built and
322
+ # before starting your production server.
323
+ cache_static_manifest: "priv/static/cache_manifest.json" ,
324
+ url: [ host: host , port: 443 , scheme: "https" ] ,
325
+ http: [
326
+ # Enable IPv6 and bind on all interfaces.
327
+ # Set it to {0, 0, 0, 0, 0, 0, 0, 1} for local network only access.
328
+ # See the documentation on https://hexdocs.pm/plug_cowboy/Plug.Cowboy.html
329
+ # for details about using IPv6 vs IPv4 and loopback vs public addresses.
330
+ ip: { 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 } ,
331
+ port: port
332
+ ]
333
+ ]
334
+ end
335
+
336
+ config :epochtalk_server , EpochtalkServerWeb.Endpoint ,
337
+ Keyword . merge ( base_endpoint_config , endpoint_config )
296
338
339
+ if config_env ( ) == :prod do
297
340
# ## Configuring the mailer
298
341
#
299
342
# In production you need to configure the mailer to use a different adapter.
0 commit comments