Skip to content

TypeScript support for setupProxy #6794

@dannycochran

Description

@dannycochran

I understand the docs specifically call out that the setupProxy file does not support additional languages. However, without TypeScript support, the setupProxy file cannot import other TypeScript code from within src.

My use case:

// src/setupProxy.js
//
// @ts-ignore: isolated modules error
const proxy = require('http-proxy-middleware');
const backends = require('./common/backends');
const addressInfo = backends.getServerAddress();

module.exports = function (app) {
  app.use(proxy([
    backends.apiRoot,
    backends.graphqlRoot,
    backends.mediaRoot,
  ], { target: `http://${addressInfo.host}:${addressInfo.port}/` }));
};

This will result in an error, Cannot find module './common/backends', which makes sense because ./common/backends is a TypeScript file. However, I would be able to require this file if my project were JavaScript.

Without this, I'll have to duplicate the addressInfo and path locations from backends in setupProxy.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions