Running Java Spring Boot + React in Docker container on Web Services

I am trying to run a docker container with spring-boot + react app and it building with no issue and working fine locally, but after deploying it on render it throws an error.
It’s a Cors error, any idea how to fix this issue?

FrontEnd :

import axios from ‘axios’;

export const addLinks = async (link, enable) => {

 const baseUrl = process.env.REACT_APP_BASE_URL;
 const url = `${baseUrl}/urlData/insert`;

const list = []

let response;

try {
    response = await, list, {
        headers: {
            'Content-Type': 'application/json',
        params: {
            'jsEnable': enable
        date: list
    // return response;

} catch (error) {
    console.error('Error fetching images:', error);
    throw error;
finally {
    return response;


Backend :


@CrossOrigin(origins = “", allowedHeaders = "”, maxAge = 3600L, methods = {RequestMethod.GET, RequestMethod.OPTIONS, RequestMethod.POST})
public class UrlDataController {

private UrlDataService urlDataService;

public ResponseEntity<?> insertBulk(@RequestBody List<String> urls, @RequestParam("jsEnable") Boolean jsEnable) {"LINK ADDED " + urls.get(0) + " AND JS ENABLE " + jsEnable);
    UrlData data = null;
    try {
        data = urlDataService.getData(urls, jsEnable);
    } catch (Exception e) {
        return ResponseEntity.internalServerError().body("SOMETHING WENT WRONG");
    if (data == null) {
        return ResponseEntity.status(204).build();
    return ResponseEntity.status(200).build();

public ResponseEntity<?> getAllTags() {"TAGS REQUESTED");
    List<String> list = urlDataService.getAllTags();
    return ResponseEntity.ok().body(list);

public ResponseEntity<?> search(@PathVariable String keyword) {"KEYWORD SEARCH REQUESTED");
    return ResponseEntity.ok().body(urlDataService.searchString(keyword));

public ResponseEntity<?> getImages() throws Exception {"GET IMAGES REQUESTED");
    return ResponseEntity.of(Optional.ofNullable(urlDataService.images()));

public ResponseEntity<?> getData() throws IOException {"GET ZIP FILE REQUESTED");
    Resource file = urlDataService.sendZip();
    if (file == null) {
        MyLogger.warn("REQUEST NOT COMPLETED");
        return ResponseEntity.status(500).build();
    HttpHeaders headers = new HttpHeaders();
    headers.setContentDispositionFormData("attachment", "");
    return ResponseEntity.ok()



package com.url.extractor.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.cors.CorsConfiguration;
import org.springframework.web.cors.CorsConfigurationSource;
import org.springframework.web.cors.UrlBasedCorsConfigurationSource;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import java.util.Arrays;
import java.util.List;

public class Config implements WebMvcConfigurer {

public CorsConfigurationSource corsConfigurationSource() {
    CorsConfiguration configuration = new CorsConfiguration();
    configuration.setAllowedMethods(Arrays.asList("GET", "POST", "PUT", "DELETE", "OPTIONS"));
    UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();
    source.registerCorsConfiguration("/**", configuration);
    return source;

public void addInterceptors(InterceptorRegistry registry) {
    registry.addInterceptor(new RateLimitInterceptor()).addPathPatterns("/**", "/urlData/getData");



Stage 1: Setup Nginx and Node.js

FROM nginx:alpine

Update package repository and install required packages

RUN apk update &&
apk add --no-cache openjdk17 supervisor

Set the working directory for the application


Copy build files to nginx directory

COPY /url_exct_frontend/build /usr/share/nginx/html

Copy jar file to app directory

COPY target/*.jar app.jar

Allow executable permissions to the jar file

RUN chmod +x app.jar

Copy supervisord configuration file

COPY supervisord.conf /etc/supervisord.conf

Expose port 80

EXPOSE 80 8080

Start supervisord to manage Java application and Nginx server

CMD [“/usr/bin/supervisord”, “-c”, “/etc/supervisord.conf”]

Hi Sushant,

Looks like the requests are still going to localhost. Did you make sure to update any references to localhost so that they point to your server now?

I’d also suggest reviewing the community for other CORS posts in case you run into additional issues that have been addressed already.



This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.