Я использую весеннюю загрузку java на сервере и веб-приложение, построенное на react. По какой-то причине, которую я не могу понять, я не могу получить доступ к своим компонентам реакции по URL-адресу. Например: https://myapp.appspot.com/profile дает мне ошибку 404. Для этого есть причина? Из-за движка приложения я настраиваю сервлет с кодом, который я нашел в Интернете. все работает для обычного пути ("/"), но когда я пробую "/ profile", говорит, что его не существует, даже если он существует. В react localhost он работает отлично.
Setup
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.jackson.JacksonAutoConfiguration;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
import org.springframework.scheduling.annotation.EnableScheduling;
@SpringBootApplication(exclude = { JacksonAutoConfiguration.class })
@EnableScheduling
public class Backend {
public static void main(String[] args) {
SpringApplication.run(Backend.class, args);
}
public static class ServletInitializer extends SpringBootServletInitializer {
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
return application.sources(Backend.class);
}
}
}
web. xml
<?xml version="1.0" encoding="utf-8"?>
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
version="3.1">
<welcome-file-list>
<welcome-file>index.html</welcome-file>
</welcome-file-list>
<error-page>
<error-code>404</error-code>
<location>/../index.html</location>
</error-page>
</web-app>
app-engine. xml
<?xml version="1.0" encoding="utf-8"?>
<appengine-web-app
xmlns="http://appengine.google.com/ns/1.0">
<threadsafe>true</threadsafe>
<runtime>java8</runtime>
<sessions-enabled>false</sessions-enabled>
<system-properties>
<property name="java.util.logging.config.file"
value="WEB-INF/logging.properties" />
</system-properties>
<static-files>
<include path="/**.html" />
<include path="/**.png" />
<include path="/**.ico" />
<include path="/**.txt" />
<include path="/**.json" />
<include path="/**.js" />
<include path="/**.svg" />
<include path="/**.jpg" />
<include path="/**.map" />
<include path="/**.css" />
</static-files>
<resource-files>
<include path="/**.html" />
<include path="/**.png" />
<include path="/**.ico" />
<include path="/**.txt" />
<include path="/**.json" />
<include path="/**.js" />
<include path="/**.svg" />
<include path="/**.jpg" />
<include path="/**.map" />
<include path="/**.css" />
</resource-files>
<automatic-scaling>
<target-cpu-utilization>0.9</target-cpu-utilization>
<max-instances>30</max-instances>
<min-instances>1</min-instances>
<max-concurrent-requests>15</max-concurrent-requests>
<max-idle-instances>2</max-idle-instances>
</automatic-scaling>
</appengine-web-app>