Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

354
Views
On Github Pages you can run a React application as a single file and call it as a function. What's the best way to do that on Google Cloud Platform?

I have a Github repo that has Pages enabled. In Pages, I have an index.js that contains a function. The function is run automatically when you hit an HTTP endpoint. The application is a widget, so it's not like I want to host a whole website. I jsut want to be able to hit an endpoint from a <script> tag and run my code in a third-party site.

The index.js file is created by building my React app with Parcel and compiling it down to a single js file. The file itself runs an IIFE - this is created by Parcel after building and looks something like this:

!function(){function e(e,t,n,r){Object.defineProperty...
// hundreds of lines minified into one humongus line of code
...{domElement:e})}),e)})),Er()}();

For reference, I created it by following this tutorial, and you can see the author's script in their github repo here.

But Github PAges is public, so I wanted to move my script to GCP. I thought a simple Cloud function would do, but I get the dreaded could not handle the request error. For my Cloud Functions app I tried the following:

exports.helloWorld = (req, res) => {
  const widget = // copy in all of the above code
  res.status(200).send(widget);
}

This threw the above error.

Is there a better/different way to host a single function script like this that runs on http call?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

From what I understand, you're simply trying to host a javascript file somewhere where it can be used by other projects. If you're set on Google cloud, you could just upload your javascript file to a public bucket. Unless you want to perform any dynamic logic each time the file is requested, you don't need anything more complicated than a static host.

You mention that you want to use GCP because Github pages is public, but any file you host would be public unless you want to set up rules so that only specific domains can request the file.

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!