Rod JI
Rod JI

Reputation: 3

Render / include html file Google Cloud Functions

I am almost new with Google Cloud Functions and I would like to know if there is a way to render an html file from a function. I have a method for doing this with the method send, but as the file is too long the final code is very long and I have always deploy the functions to modify minimal things. Is there a way to include the external file or something like that? In this case I don't need to use JS variables to modify the text because this is an static info file. Right now I use this and it works:

  exports.index = functions.https.onRequest((req, res)=> { res.send(`<!doctype html>
    <head>
      <title>MY HTML</title>
           <link rel="shortcut icon"  href="https://firebasestorage.googleapis.com/v0/b/firebase-spot.com/o/favicon.ico?alt=media"/>            
    </head>        
    <body>         
      <div class='content'>...

Is there something like include('http:\path\to\index.html')?

Upvotes: 0

Views: 1281

Answers (1)

Doug Stevenson
Doug Stevenson

Reputation: 317497

There is no simple function for that. You will have to write code to make an HTTP request to fetch the external content, download it, then send it to the client.

Upvotes: 1

Related Questions