Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • C create-react-app
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 1,547
    • Issues 1,547
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 417
    • Merge requests 417
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • Meta
  • create-react-app
  • Issues
  • #6794
Closed
Open
Issue created Apr 11, 2019 by Administrator@rootContributor

TypeScript support for setupProxy

Created by: 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.

Assignee
Assign to
Time tracking