-
Notifications
You must be signed in to change notification settings - Fork 28
Open
Description
The TemplateServer doesn't support CORS. I added following lines in Startup.cs
public void ConfigureServices(IServiceCollection services)
{
services.AddCors(options =>
{
options.AddDefaultPolicy(
policy =>
{
policy
.WithOrigins("http://localhost:3000", "http://localhost:3001")
.AllowAnyHeader()
.AllowAnyMethod();
});
});
services.AddMvc(options => options.EnableEndpointRouting = false);
}
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
{
app.UseCors();
app.UseMvc();
}
It works well on Windows, but it dosn't works as expected in Docker container.
Then I tried to run modified TemplateServer in Docker container with the following Dockerfile:
FROM mcr.microsoft.com/dotnet/sdk AS build
# copy csproj and restore as distinct layers
WORKDIR /source
COPY TemplaterServer.sln .
COPY Advanced/TemplaterServer/*.csproj ./Advanced/TemplaterServer/
RUN dotnet restore
# copy everything else and build app
COPY Advanced/TemplaterServer/. ./Advanced/TemplaterServer/
WORKDIR /source/Advanced/TemplaterServer
#RUN dotnet publish -c release -o /app --no-restore
RUN dotnet publish -c release -o /app
# final stage/image
FROM mcr.microsoft.com/dotnet/aspnet
WORKDIR /app
COPY --from=build /app ./
COPY dotnet-install.sh ./
RUN apt update && apt upgrade
RUN yes | apt install curl
RUN yes | apt install libc6-dev
RUN yes | apt install libgdiplus
RUN ./dotnet-install.sh --architecture x64 --install-dir /usr/share/dotnet/ --runtime aspnetcore --version 3.1.0
ENTRYPOINT ["dotnet", "TemplaterServer.dll"]
docker build --pull -t templateserver .
docker run --rm -it -p 8000:80 templateserver
It runs successfully, but CORS doesn't work. Also there is issues in the interface of the web-page. It doesn't switch between json examples and doesn't process the templates.
What might be the reason of that?
Is the way to add CORS support in java version of the TemplateServer?
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels