Let’s say I have the following in my netlify.toml file:
[[redirects]]
from = "/external-service/*/link.js"
to = "https://api.external-service.io/v1/:splat/analytics.min.js"
status = 200
force = true
The * can be anything (we don’t need to know what it is explicitly).
However when doing this the redirect doesn’t work. Instead the netlify site actually tries to find this explicit file and naturally can’t find it. So for example doing the following tries to resolve
Without knowing your set-up, I can only say that you have to have the explicit path to the JS file for the redirect. If you have only one or two, this should be trivial. If you have different link.js files scattered around your site, then you’ll have to refactor to get around this.
Yeah so the random string that is between the URL is served from a 3rd party so will never be consistent which is a little awkward, essentially I just need the URL to be able to appear as if it’s being served from the domain being visited and remove the word analytics
just to update @gregraven i have added the following to my _redirect /segments/file.js https://cdn.external-service.com/analytics.js/v1/my-super-secret-write-key/analytics.min.js 200
I replace my-super-secret-write-key with sed at build time, however it appears the file is still not being found when I do <script async src="/segments/file.js"></script>
Is there any particular reason this isn’t working?
The word “token” sounds a bit like it would do something magical, but is actually not a special word. The placeholder could be “toaster” as long as it matches