0

I have a nodejs backend and an angular frontend app in the same folder. The angular app outputs the build files to a static folder and nodejs uses the following to load the html file


//Idiomatic expression in express to route and respond to a client request
app.get('/', (req, res) => {        //get requests to the root ("/") will route here
    res.sendFile(process.cwd()+"/angularApp/static/index.html")      //server responds by sending the index.html file to the client's browser
                                                        //the .sendFile method needs the absolute path to the file, see: https://expressjs.com/en/4x/api.html#res.sendFile 
});

This is my app.yaml for nodejs :

    runtime: nodejs16
handlers:
- url: /
  static_files: angularApp/static/index.html
  upload: angularApp/static/index.html
- url: /
  static_dir: angularApp/static

However when I deploy the app to GCP I get the following errors in the console

Failed to load module script: Expected a JavaScript module script but the server responded with a MIME type of "text/html". Strict MIME type checking is enforced for module scripts per HTML spec.

What should the app.yaml file contain?

1 Answer 1

0

Tou can take a look of how docker works. Basically, you put your dependencies and source code into an image, then you ca easily deploy it on google cloud platform https://cloud.google.com/run/docs/deploying .

Sign up to request clarification or add additional context in comments.

2 Comments

Is there any other way apart from this? I am not able to use Docker for this
You can create a virtual machine cloud.google.com/compute . There you can ssh into your instance, install your dependencies manually, then you can start your server exacly like you do locally.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.