Serving an XML file from Glitch app

Hey there,

I need to call a URL from a nodeJS function. The URL references an XML file that I’d like to store within my Glitch app. Can I store the XML file within my app and reference it with a local URL? I’ve been playing around with the Assets and public folders but can’t seem to get it to work.


Hey, I think you can just upload the XML file to assets. Once uploaded you should be able to click on it and it should present you the option to copy the URL.

Is the issue that you can’t find the URL, or is it that you are having an issue referencing it?

Hi @esouthren, welcome to the Glitch Forums!

Like @WenInCode I’ve been able to access an XML doc both in a public folder served statically by Express and via the Assets drawer without any difficulty - you can see it in!/anonymous-anaconda, there’s a public/api.xml file and one in Assets both of which are reachable in the browser at their expected URLs.

Can you give us a code snippet of how you’re trying to access it, or a project name that we can look at?

Thanks for the reply!

Here’s the app:!/twilio-quest-voice-example

This issue is line 37. I need to reference the URL of the XML file, rather than the XML itself.

Oh I see. I think you are trying to get the URL from the XML file you uploaded to assets. I think you can do something similar to, where you parse the xml file to get the url in the Play section.

snippet from the linked stack overflow answer

fs = require('fs');
var parser = require('xml2json');

fs.readFile( './data.xml', function(err, data) {
    var json = parser.toJson(data);
    console.log("to json ->", json);

Let me know if I am misunderstanding :blush:

Thank you for the reply - but what I need is the URL of the whole XML file (I don’t know why I can’t pass the XML through the function :confused: ).

For context, if I use this URL - - it works fine.

If I take the XML from the above URL and add it to my assets file as response.xml, and reference the full URL in my function - it doesn’t work. It can find it now, but the XML isn’t processed by Twilio (that could be a non-Glitch related error though).

Update: When I try and use the assets/response.xml full URL, on the Twilio side of things I get a 405: Method Not Allowed error.

Their troubleshooting page advises:

* Make sure your web server allows HTTP POST requests to static resources (if the URL refers to .xml or .html files)

That’s potentially useful from the Glitch side of things. What do you see when you host the xml file in your regular file system and server it via a public address (as opposed to in assets)?

How do you reference the public address -, or something similar?

Yep! That’s it exactly!

If it’s been more than 5 minutes since your last request you project may take a little longer to respond since it will have gone to sleep, so if it appears to be timing out you could try it again and see if the result is different.

Aye, I just got a timeout - I’ll give it a few minutes then try again :slight_smile:

Actually you might want to try again right away. The timeout might be because your project is waking up, and if you wait too long it will go back to sleep.

You can use UptimeRobot or something similar to keep it awake all the time if that’s a continual problem.

Persistent timeout errors, unfortunately. I’ve tried half a dozen times in a row.


Code 11200 refers to a “HTTP retrieval error”.

I get an identical error if I put a typo into the URL, so it’s perhaps an issue with the parameter?

I don’t know much about Twilio; what are they trying to POST there? On closer examination I don’t think using a static url is going to allow that either.

Depending on what they require you may need to implement an endpoint they can POST to and then handle the resulting input appropriately. What’s the overall expected workflow supposed to look like?

Not entirely sure what they’re posting.

Note that if the URL parameter is, it works, but the assets/response.xml URL does not - even though they contain exactly the same XML data.

this appears when I enter an xml file: This XML file does not appear to have any style information associated with it. The document tree is shown below.

Hi, @CookieHTML! This is normal for XML files to happen when they do not have any style information associated with them. This will not cause any issue. :slightly_smiling_face:

1 Like

its css? type <link rel = "stylesheet" href = "style.css"> @R4356th

Like this- <?xml-stylesheet href="style.css"?>