captcha-com / angular-captcha

BotDetect CAPTCHA: Angular Captcha Module (TypeScript: Angular 2/4/5/6/7/8+).
https://captcha.com/angular-captcha.html
16 stars 10 forks source link

The requested captchaStyle 'yourFirstCaptchaStyle' is not defined in the botdetect.xml! #7

Closed ibtissambth closed 3 years ago

ibtissambth commented 3 years ago

Hey, I use angular-captcha with angular frontend and spring backend. I did all the steps defined in https://captcha.com/angular-captcha.html#angular-java-spring-backend:springboot-autoconfiguration but when I call my-api-endpoint/simple-captcha-endpoint?get=html&c=yourFirstCaptchaStyle its gives me the followeing error

{ "timestamp": "2021-02-08T00:37:14.011+0000", "status": 400, "error": "Bad Request", "message": "The requested captchaStyle 'yourFirstCaptchaStyle' is not defined in the botdetect.xml!", "path": "//simple-captcha-endpoint" }

here is my botdetect.xml file content : <?xml version="1." encodi0ng="UTF-8"?> `<botdetect xmlns="https://captcha.com/schema/java" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="https://captcha.com/schema/java https://captcha.com/schema/java/botdetect-4.0.beta3.7.xsd">

yourFirstCaptchaStyle yourFirstCaptchaUserInput

`

did I miss something ? thanks in advance

ibtissambth commented 3 years ago

I dont know why I get this error just when working on https domain, but not on http://localhost

ibtissambth commented 3 years ago

"BDC_configFileLocation", "/WEB-INF/classes/botdetect.xml");

The path /WEB-INF/classes/botdetect.xml worked for me

botdetect-support commented 3 years ago

Where is botdetect.xml located? In the /WEB-INF/folder of your app, or in the /resources/ folder?

If it is in /WEB-INF/folder, please try to move it to /resources/ folder, and configure the path to botdetect.xml in the following way:

@SpringBootApplication
public class YourAppBackend {

    [...]

    @Bean
    public ServletContextInitializer initializer() {
        return new ServletContextInitializer() {

            @Override
            public void onStartup(ServletContext servletContext) throws ServletException {
                servletContext.setInitParameter(
                    "BDC_configFileLocation", "/resources/botdetect.xml");
            }
        }
    }
}

Hope this helps.