Using 'fetch' command for react-app

I’m trying to build a worker which will use the “fetch” command to serve the user from some URL.
This URL is in fact a react-app stored on AWS. Here is my snippet:

async function eventHandler(event) {
    const resp = await fetch('',{ headers: { 'content-type': 'text/html' }});
    return resp

while open the browser at the relevant URL it seems the fetch did get the files from AWS, but is unable to render the app with this error in the console - " Unexpected token ‘<’ ".
It looks to me like it fails parsing the index.html file.

Is there a best practice or some kind of ‘options flag’ which need to be use for fetching a ‘react-app’, or is it like any other URL?

Thanks in advance.

May I ask you to provide the complete and exact response body?
Can you check in your Web browser → Network tab the actual response you are receiving from the server?
Maybe the response data you are getting is the actually HTML?

You are requesting something, and expect it a return in text/html.
Maybe it returns the Content-Type:application/json instead of text/html format?

Can you try adding prefix https:// before and a slash / to the end?

  • like:

And maybe changing to application/json would be the solution like:

async function eventHandler(event) {
    const resp = await fetch('', { # here I added https:// prefix and a slash to the end /
        method: 'GET', # added, just in case ...
        headers: {
           'content-type': 'application/json' } # changed from text/html ...
    return resp; # does it miss the semicolon here too or not?

Try adding the output in the console, just in case:

Using await inside async function looks good to me.
I am afraid this or something in your JSON formatted block is not correct and/or valid as is.
Otherwise, if JSON response, you need to parse it.