从 Phoenix 提供静态 TXT 文件

Serving Static TXT Files from Phoenix

我需要从我的 Phoenix 应用程序提供静态 TXT 文件,用于域验证目的:

• Google 搜索控制台

• GoGetSSL认证

两家公司都要求我上传一个不同的 TXT 文件,这些文件将在我的域的根路径上进行验证。

像这样:http://example.com/091823091231902322389.txt

我下载了 TXT 文件并将其放入 web/static/assets 文件夹。

但是当尝试使用浏览器访问它时,我显然得到了 no route found for GET

如何确保 Phoenix 提供 web/static/assets 文件夹中的文件?

将文件添加到web/static/assets后,还需要将文件名添加到Plug.Static白名单。在您的 lib/my_app/endpoint.ex 中,更改:

plug Plug.Static,
  at: "/", from: :my_app, gzip: false,
  only: ~w(css fonts images js favicon.ico robots.txt)

plug Plug.Static,
  at: "/", from: :my_app, gzip: false,
  only: ~w(css fonts images js favicon.ico robots.txt 091823091231902322389.txt)