I’m trying to return a plain javascript if a user access to a given route inside my app. I want to give users the oportunity to include scripts from my site inside theirs, like
this:
<script src="MY_DOMAIN/foo">
If I write:
app.get('/foo', function (req,res) {
res.end("document.write('<p>Hello</p>'");
});
The returned javascript includes all the layout so the client browser can’t handle it.
Ahy idea?
Thanks in advance
You need to set the content type.