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?
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)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With