Files
backstage/.changeset/fast-trees-arrive.md
T
Fredrik Adelöw 3108ff7bfd Make yarn dev for backends respect the PLUGIN_PORT env var
Signed-off-by: Fredrik Adelöw <freben@gmail.com>
2021-06-14 14:46:19 +02:00

781 B

@backstage/cli
@backstage/cli
patch

Make yarn dev in newly created backend plugins respect the PLUGIN_PORT environment variable.

You can achieve the same in your created backend plugins by making sure to properly call the port and CORS methods on your service builder. Typically in a file named src/service/standaloneServer.ts inside your backend plugin package, replace the following:

const service = createServiceBuilder(module)
  .enableCors({ origin: 'http://localhost:3000' })
  .addRouter('/my-plugin', router);

With something like the following:

let service = createServiceBuilder(module)
  .setPort(options.port)
  .addRouter('/my-plugin', router);
if (options.enableCors) {
  service = service.enableCors({ origin: 'http://localhost:3000' });
}