Skip to content

Allow serving virtual files #223

@lmeysel

Description

@lmeysel

We just stumbled across the issue where we needed to create a file dynamically and serve it.

Our usecase:
We need to inject environment variables from the server prefixed by REACT_APP_. I guess the normal case is, that these env vars cannot be known at built time, thus are not baked into the assets. We need to supply them dynamically. We used to handle this using the react-inject-env package, but now we have an environment where the file system is readonly, thus it cannot create the env.js and therefore this approach becomes useless.

It would be nice to have an additional configuration option, e.g.

handler(request, response, {
  virtualFiles: [
    { source: 'env.js', content: myPreComputedEnvJs, type: 'application/json' }
  ]
})

which should also integrate nicely with e.g. the headers field.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions