Skip to content

invalid conversion from 'const AsyncWebHeader*' to 'AsyncWebHeader*' #335

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Open
towerofpower256 opened this issue May 14, 2025 · 1 comment

Comments

@towerofpower256
Copy link

towerofpower256 commented May 14, 2025

When I try to build from the repo 2025-05-14 5:55am GMT, I get the below error:

lib/framework/SecuritySettingsService.cpp:18:59: error: invalid conversion from 'const AsyncWebHeader*' to 'AsyncWebHeader*'
AsyncWebHeader* authorizationHeader = request->getHeader(AUTHORIZATION_HEADER);

and

lib/framework/SecuritySettingsService.cpp:26:58: error: invalid conversion from 'const AsyncWebParameter*' to 'AsyncWebParameter*'
AsyncWebParameter* tokenParamater = request->getParam(ACCESS_TOKEN_PARAMATER);

It looks like the request->getHeader() and request->getParam() functions return const AsyncWebHeader* instead of AsyncWebHeader*. I suspect that the ESPAsyncWebServer has been updated and doesn't work with esp8266-react anymore.

@towerofpower256
Copy link
Author

towerofpower256 commented May 14, 2025

Changing the below 2 lines, adding const in front, seems to do the job. It now builds, and as far as I can tell it still works the same.

Before:

Authentication SecuritySettingsService::authenticateRequest(AsyncWebServerRequest* request) {
  AsyncWebHeader* authorizationHeader = request->getHeader(AUTHORIZATION_HEADER);
  if (authorizationHeader) {
    String value = authorizationHeader->value();
    if (value.startsWith(AUTHORIZATION_HEADER_PREFIX)) {
      value = value.substring(AUTHORIZATION_HEADER_PREFIX_LEN);
      return authenticateJWT(value);
    }
  } else if (request->hasParam(ACCESS_TOKEN_PARAMATER)) {
    AsyncWebParameter* tokenParamater = request->getParam(ACCESS_TOKEN_PARAMATER);
    String value = tokenParamater->value();
    return authenticateJWT(value);
  }
  return Authentication();
}

After

Authentication SecuritySettingsService::authenticateRequest(AsyncWebServerRequest* request) {
  const AsyncWebHeader* authorizationHeader = request->getHeader(AUTHORIZATION_HEADER);
  if (authorizationHeader) {
    String value = authorizationHeader->value();
    if (value.startsWith(AUTHORIZATION_HEADER_PREFIX)) {
      value = value.substring(AUTHORIZATION_HEADER_PREFIX_LEN);
      return authenticateJWT(value);
    }
  } else if (request->hasParam(ACCESS_TOKEN_PARAMATER)) {
    const AsyncWebParameter* tokenParamater = request->getParam(ACCESS_TOKEN_PARAMATER);
    String value = tokenParamater->value();
    return authenticateJWT(value);
  }
  return Authentication();
}

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant