@equinor/fusion-framework-dev-server 2.0.19 → 2.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -75,14 +75,22 @@ export const processServices: ApiDataProcessor<FusionService[]> = (data, args) =
75
75
  const serviceUrl = new URL(`${route}/${service.key}`, request.headers.referer);
76
76
  apiServices.push({ ...service, uri: String(serviceUrl) });
77
77
 
78
- // add the proxy route
78
+ // Add the proxy route for this service.
79
79
  const url = new URL(service.uri);
80
+ const usesLocalhostSubdomain = url.hostname.endsWith('.localhost');
81
+ // Node does not resolve localhost subdomains consistently across operating systems. The mock
82
+ // server also accepts /<service>/* on plain localhost, so proxy through that portable address.
83
+ if (usesLocalhostSubdomain) {
84
+ url.hostname = 'localhost';
85
+ }
80
86
  apiRoutes.push({
81
87
  match: `/${service.key}${url.pathname}*sub`,
82
- proxy: {
83
- target: url.origin,
84
- rewrite: (path) => path.replace(`/${service.key}`, ''),
85
- },
88
+ proxy: usesLocalhostSubdomain
89
+ ? { target: url.origin }
90
+ : {
91
+ target: url.origin,
92
+ rewrite: (path) => path.replace(`/${service.key}`, ''),
93
+ },
86
94
  });
87
95
  }
88
96
  return { data: apiServices, routes: apiRoutes };
package/src/types.ts CHANGED
@@ -70,35 +70,36 @@ export { UserConfig as DevServerOverrides } from 'vite';
70
70
  * };
71
71
  * ```
72
72
  */
73
- export type DevServerOptions<TEnv extends Partial<FusionTemplateEnv> = Partial<FusionTemplateEnv>> =
74
- {
75
- /** SPA template settings. When provided, the dev server injects these values into the HTML template at serve time. */
76
- spa?: {
77
- /** Static environment object or factory function that produces it on each request. */
78
- templateEnv: TEnv | TemplateEnvFn<TEnv>;
79
- };
80
- api: {
81
- /**
82
- * The URL of the service discovery proxy endpoint.
83
- */
84
- serviceDiscoveryUrl: string;
73
+ export interface DevServerOptions<
74
+ TEnv extends Partial<FusionTemplateEnv> = Partial<FusionTemplateEnv>,
75
+ > {
76
+ /** SPA template settings. When provided, the dev server injects these values into the HTML template at serve time. */
77
+ spa?: {
78
+ /** Static environment object or factory function that produces it on each request. */
79
+ templateEnv: TEnv | TemplateEnvFn<TEnv>;
80
+ };
81
+ api: {
82
+ /**
83
+ * The URL of the service discovery proxy endpoint.
84
+ */
85
+ serviceDiscoveryUrl: string;
85
86
 
86
- /**
87
- * Route mapper for processing service discovery data.
88
- */
89
- processServices?: ApiDataProcessor<FusionService[]>;
87
+ /**
88
+ * Route mapper for processing service discovery data.
89
+ */
90
+ processServices?: ApiDataProcessor<FusionService[]>;
90
91
 
91
- /**
92
- * Additional routes to be added to the API service proxy.
93
- * @remarks used for overriding proxy responses and mocking services.
94
- */
95
- routes?: ApiRoute[];
96
- };
97
- /** Server-side (CLI) logging configuration. */
98
- log?: {
99
- /** Log verbosity: 0 = None, 1 = Error, 2 = Warning, 3 = Info, 4 = Debug. Defaults to Info (3). */
100
- level?: number;
101
- /** Custom logger instance. When omitted a default {@link ConsoleLogger} is created. */
102
- logger?: ConsoleLogger;
103
- };
92
+ /**
93
+ * Additional routes to be added to the API service proxy.
94
+ * @remarks used for overriding proxy responses and mocking services.
95
+ */
96
+ routes?: ApiRoute[];
97
+ };
98
+ /** Server-side (CLI) logging configuration. */
99
+ log?: {
100
+ /** Log verbosity: 0 = None, 1 = Error, 2 = Warning, 3 = Info, 4 = Debug. Defaults to Info (3). */
101
+ level?: number;
102
+ /** Custom logger instance. When omitted a default {@link ConsoleLogger} is created. */
103
+ logger?: ConsoleLogger;
104
104
  };
105
+ }
package/src/version.ts CHANGED
@@ -1,2 +1,2 @@
1
1
  // Generated by genversion.
2
- export const version = '2.0.19';
2
+ export const version = '2.1.0';
@@ -0,0 +1,11 @@
1
+ import { defineProject } from 'vitest/config';
2
+
3
+ import { name, version } from './package.json' with { type: 'json' };
4
+
5
+ export default defineProject({
6
+ test: {
7
+ environment: 'node',
8
+ include: ['src/**/*.test.ts'],
9
+ name: `${name}@${version}`,
10
+ },
11
+ });