Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Serving Static TXT Files from Phoenix

I need to serve a Static TXT file from my Phoenix app, for domain verification purposes:

• Google Search Console

• GoGetSSL certification

Both companies asked me to upload, each a different TXT file that would be verified on the root path of my domain.

Like so: http://example.com/091823091231902322389.txt

I downloaded the TXT file and have placed it into the web/static/assets folder.

But when trying to reach it using the browser I obviously get a no route found for GET

How can I make sure files within the web/static/assets folder are served by Phoenix?

like image 765
Jonathan Soifer Avatar asked Dec 13 '25 00:12

Jonathan Soifer


1 Answers

After adding the file to web/static/assets, you also need to add the filename to the Plug.Static whitelist. In your lib/my_app/endpoint.ex, change:

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

to

plug Plug.Static,
  at: "/", from: :my_app, gzip: false,
  only: ~w(css fonts images js favicon.ico robots.txt 091823091231902322389.txt)
like image 158
Dogbert Avatar answered Dec 15 '25 22:12

Dogbert



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!