-
I used the AspireWithNode example to have my react app in my Aspire solution, and it works. Now I would like to customize the name of the environment variable holding the URI of my I have found the code that generates the environment variable in |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 13 replies
-
You would use var weatherapi = builder.AddProject<Projects.AspireWithNode_AspNetCoreApi>("weatherapi");
builder.AddNpmApp("frontend", "../NodeFrontend", "watch")
.WithEnviroment("VITE_SOMETHING", weatherapi.GetEndpoint("http"))
.WithReference(cache)
.WithServiceBinding(scheme: "http"); |
Beta Was this translation helpful? Give feedback.
-
Hi @davidfowl, What if I want to set an environment variable to a more complex URI that contains the endpoint? If |
Beta Was this translation helpful? Give feedback.
-
@davidfowl I'm trying to do a similar thing using Yarn, but the variables are not available to read inside my application code. Any clue why?
|
Beta Was this translation helpful? Give feedback.
-
There is a problem. weatherapi.GetEndpoint("http") This returns target endpoint. But I can't get external endpoint. I want to get something like .WithEnvironment(context =>
{
// frontend.GetEndpoint("http")
string address = $"http://host.docker.internal:{frontend.GetEndpoint("http").Port
.ToString(CultureInfo.InvariantCulture)}";
context.EnvironmentVariables["FRONTEND_UKEP_ENDPOINT"] = address;
}); But it looks ugly. And I need reference to stable endpoint which will work even when I stop Aspire from VS.
var frontend = builder
.AddUkepFrontend("cm-frontend-ukep", port: 3555)
.WithExternalHttpEndpoints()
.WithLifetime(ContainerLifetime.Persistent); |
Beta Was this translation helpful? Give feedback.
You would use
WithEnvironmnt
, not with WithReference.