I want to use nginx configuration to automatically return a piece of js when accessing a certain URL, such as alert("some message")
I want to achieve this through the following configuration
location /foo {
default_type application/javascript;
return 200 '<script>alert("hello");</script>';
}
But the actual access in the browser only returns text
<script>alert("hello");</script>
No dialog box pops up. Can nginx support returning js? How to configure it correctly?
学习是最好的投资!