Heroku with Cors error

Asked

Viewed 94 times

-1

I have Cors problem in Heroku.

Cors class

@Configuration
public class WebConfig implements WebMvcConfigurer {

  @Override
  public void addCorsMappings(CorsRegistry registry) {
    registry.addMapping("/**")
    .allowedMethods("*")
    ;
  }
}

Procfile -> web: java -Dserver.port=$PORT -Dspring.profiles.active=Prod -jar target/queroparcelado-0.0.1-SNAPSHOT. jar release: . /mvnw flyway:migrate

system properties. -> java.runtime.version=15

Error that appears in the ui console

Access to Xmlhttprequest at 'https://queroparcelado-api.herokuapp.com/client' from origin 'https://queroparcelado-ui.herokuapp.com' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested source.

Error that appears in the Heroku api console

at=error code=H10 desc="App Crashed" method=GET path="/client" host=queroparcelado-api.herokuapp.com request_id=bd529d7b-bbac-48eb-9c82-722379fbb59f Fwd="191.190.92.249" Dyno= connect service= status=503 bytes= Protocol=https

1 answer

0

All the indications were pom trouble.

first to streamline I started to run the project on local Heroku using "local Heroku" and see what was the problem.

all changes were made to the plugins of the pom stay at the end so.

<build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.7.0</version>
                <configuration>
                    <source>15</source>
                    <target>15</target>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.flywaydb</groupId>
                <artifactId>flyway-maven-plugin</artifactId>
                <configuration>
                    <!--suppress UnresolvedMavenProperty -->
                    <url>${env.JDBC_DATABASE_URL}</url>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <configuration>
                    <mainClass>br.com.queroparcelado.QueroparceladoApplication</mainClass>
                </configuration>
                <executions>
                    <execution>
                        <goals>
                            <goal>repackage</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>2.19.1</version>
            </plugin>
        </plugins>
    </build>

Browser other questions tagged

You are not signed in. Login or sign up in order to post.