CORS error while redirecting angular page from spring boot: header field content-type is not allowed by Access-Control-Allow-Headers in preflightError :Request header field Content-Type is not allowed by Access-Control-Allow-HeadersWhy does my JavaScript get a “No 'Access-Control-Allow-Origin' header is present on the requested resource” error when Postman does not?Request header field Access-Control-Allow-Headers is not allowed by Access-Control-Allow-HeadersSpring Boot swallowing Access-Control-Request-Headers on OPTIONS preflightMissing token 'access-control-allow-headers' in CORS header 'Access-Control-Allow-Headers' from CORS preflight channelRequest header field Access-Control-Allow-Headers is not allowed by itself in preflight responseNo 'Access-Control-Allow-Origin' header is present on the requested resource—when trying to get data from a REST APISpring Boot, Angular 2, CORS “Request header field authorization is not allowed by Access-Control-Allow-Headers in preflight response.”CORS fails, but CORS headers are present, error: Cache-Control is not allowed by Access-Control-Allow-Headers in preflight responseAngular Spring Boot: Redirection error: Request header field Content-Type is not allowed by Access-Control-Allow-Headers in preflight response

How can I finally understand the confusing modal verb "мочь"?

Antivirus for Ubuntu 18.04

How can I test a shell script in a "safe environment" to avoid harm to my computer?

The unknown and unexplained in science fiction

Which "exotic salt" can lower water's freezing point by 70 °C?

Why always 4...dxc6 and not 4...bxc6 in the Ruy Lopez Exchange?

Employee is self-centered and affects the team negatively

Bash prompt takes only the first word of a hostname before the dot

Game artist computer workstation set-up – is this overkill?

What's the difference between "ricochet" and "bounce"?

Why is the blank symbol not considered part of the input alphabet of a Turing machine?

How to increase speed on my hybrid bike with flat handlebars and 700X35C tyres?

Gift for mentor after his thesis defense?

Splitting polygons and dividing attribute value proportionally using ArcGIS Pro?

What does the copyright in a dissertation protect exactly?

Can anyone identify this unknown 1988 PC card from The Palantir Corporation?

Was there a dinosaur-counter in the original Jurassic Park movie?

I want to write a blog post building upon someone else's paper, how can I properly cite/credit them?

Latex editor/compiler for Windows and Powerpoint

Why is there a cap on 401k contributions?

How to make a kid's bike easier to pedal

What is the meaning of "matter" in physics?

Is throwing dice a stochastic or a deterministic process?

Convert a huge txt-file into a dataset



CORS error while redirecting angular page from spring boot: header field content-type is not allowed by Access-Control-Allow-Headers in preflight


Error :Request header field Content-Type is not allowed by Access-Control-Allow-HeadersWhy does my JavaScript get a “No 'Access-Control-Allow-Origin' header is present on the requested resource” error when Postman does not?Request header field Access-Control-Allow-Headers is not allowed by Access-Control-Allow-HeadersSpring Boot swallowing Access-Control-Request-Headers on OPTIONS preflightMissing token 'access-control-allow-headers' in CORS header 'Access-Control-Allow-Headers' from CORS preflight channelRequest header field Access-Control-Allow-Headers is not allowed by itself in preflight responseNo 'Access-Control-Allow-Origin' header is present on the requested resource—when trying to get data from a REST APISpring Boot, Angular 2, CORS “Request header field authorization is not allowed by Access-Control-Allow-Headers in preflight response.”CORS fails, but CORS headers are present, error: Cache-Control is not allowed by Access-Control-Allow-Headers in preflight responseAngular Spring Boot: Redirection error: Request header field Content-Type is not allowed by Access-Control-Allow-Headers in preflight response






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;








1















I am developing an application with angular 6 as front end and spring boot as back end. Currently I am working with forgot password functionality :



  1. Taking email id from angular and sending an email to the id.

@RequestMapping(value = "/forgotPassword", method = RequestMethod.POST)
public ResponseEntity<?> forgotPassword(@RequestParam("email") String recepientemail, HttpServletRequest request)
Optional<User> userlist = userRepository.findByEmail(recepientemail);
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
if (userlist.isPresent())
User u = userlist.get();
u.setResetToken(UUID.randomUUID().toString());
u.setResetTokenExpiry(simpleDateFormat.format(DateUtils.addDays(new Date(), 1)));
u.setModifiedBy(u.getId());
u.setModifiedDate(simpleDateFormat.format(new Date()));
userRepository.save(u);
String appUrl = request.getScheme() + "://" + request.getServerName() + ":" + request.getLocalPort();

// Email message
email.sendSimpleEmail(u.getEmail(), "DIS Password Reset Request",
"To reset your password, click the link below:n" + appUrl + "/dis/resetPassword?resetToken="
+ u.getResetToken());
return new ResponseEntity<>(
new ResponseMessage("A password reset link has been sent to registered email address!"),
HttpStatus.OK);

return new ResponseEntity<>(new ResponseMessage("We didn't find an account for this e-mail address!"),
HttpStatus.BAD_REQUEST);



  1. By clicking on link spring boot will redirect to the angular's reset password page.

@RequestMapping(value = "/resetPassword", method = RequestMethod.GET)
public ModelAndView displayResetPasswordPage(@RequestParam("resetToken") String token) throws ParseException
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
Optional<User> user = userRepository.findUserByResetToken(token);
ModelAndView modelAndView = new ModelAndView();
if (user.isPresent()) // Token found in DB
if (simpleDateFormat.parse(user.get().getResetTokenExpiry()).after(new Date()))
modelAndView.addObject("resetToken", token);
modelAndView.setViewName("redirect:http://localhost:4200/reset-password");
else
modelAndView.addObject("errorMessage", "Oops! Your password reset link has expired.");
modelAndView.setViewName("redirect:http://localhost:4200/forgot-password");

else // Token not found in DB
modelAndView.addObject("errorMessage", "Oops! This is an invalid password reset link.");
modelAndView.setViewName("redirect:http://localhost:4200/forgot-password");

return modelAndView;



  1. By entering the new password on reset page, angular will pass the reset token and new password to spring boot and then spring boot should redirect to login page after successful change of password.

@RequestMapping(value = "/processResetPassword", method = RequestMethod.POST)
public ModelAndView setNewPassword(@RequestBody Map<String, String> requestParams, RedirectAttributes redir, HttpServletResponse response)
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
Optional<User> user = userRepository.findUserByResetToken(requestParams.get("resetToken"));
ModelAndView modelAndView = new ModelAndView();
if (user.isPresent())
User resetUser = user.get();
resetUser.setPassword(encoder.encode(requestParams.get("password")));
resetUser.setResetToken(null);
resetUser.setResetTokenExpiry(null);
resetUser.setModifiedBy(resetUser.getId());
resetUser.setModifiedDate(simpleDateFormat.format(new Date()));
userRepository.save(resetUser);
//redir.addFlashAttribute("successMessage", "You have successfully reset your password. You may now login.");
//modelAndView.addObject("successMessage", "You have successfully reset your password. You may now login.");
modelAndView.setViewName("redirect:http://localhost:4200");
return modelAndView;
else
modelAndView.addObject("errorMessage", "Oops! This is an invalid password reset link.");
modelAndView.setViewName("redirect:http://localhost:4200/forgot-password");

return modelAndView;



Now the problem is, in second point spring boot is able to redirect the reset password page perfectly but in third point while redirecting to login page it is giving CORS error. Why?



Here is the screenshot of error screenshot



Edit:
Here is cross origin annotation



@CrossOrigin(origins = "*", maxAge = 3600)
@RestController
@RequestMapping("/dis")
public class AuthRestAPIs ....


and here is the request header at network request header










share|improve this question
























  • I don't see an @CrossOrigin annotation anywhere, and you didn't show the HTTP headers from your network requests. As a note, passing HttpServletRequest is nearly always a sign that you are taking more trouble than is necessary. In this case, pass UriComponentsBuilder instead; you can use MvcUriComponentsBuilder.relativeTo to create the link you want in a much cleaner fashion.

    – chrylis
    Mar 23 at 6:58











  • @chrylis , Hey, I have update my question with @CrossOrigin and request header, please have a look and also, I am passing HttpServletRequest in forgotPassword method and that's working fine. Moreover, in setNewPassword method else part is working fine, it is perfectly redirect to forgot password page, so, i am confused that what's the problem with if part in the same, why it is providing null in request header origin

    – Divyani Garg
    Mar 23 at 7:26











  • Your CORS configuration needs to be updated so that the server sends back an Access-Control-Allow-Headers response header that includes 'Content-Type' in its value.

    – sideshowbarker
    Mar 23 at 23:34

















1















I am developing an application with angular 6 as front end and spring boot as back end. Currently I am working with forgot password functionality :



  1. Taking email id from angular and sending an email to the id.

@RequestMapping(value = "/forgotPassword", method = RequestMethod.POST)
public ResponseEntity<?> forgotPassword(@RequestParam("email") String recepientemail, HttpServletRequest request)
Optional<User> userlist = userRepository.findByEmail(recepientemail);
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
if (userlist.isPresent())
User u = userlist.get();
u.setResetToken(UUID.randomUUID().toString());
u.setResetTokenExpiry(simpleDateFormat.format(DateUtils.addDays(new Date(), 1)));
u.setModifiedBy(u.getId());
u.setModifiedDate(simpleDateFormat.format(new Date()));
userRepository.save(u);
String appUrl = request.getScheme() + "://" + request.getServerName() + ":" + request.getLocalPort();

// Email message
email.sendSimpleEmail(u.getEmail(), "DIS Password Reset Request",
"To reset your password, click the link below:n" + appUrl + "/dis/resetPassword?resetToken="
+ u.getResetToken());
return new ResponseEntity<>(
new ResponseMessage("A password reset link has been sent to registered email address!"),
HttpStatus.OK);

return new ResponseEntity<>(new ResponseMessage("We didn't find an account for this e-mail address!"),
HttpStatus.BAD_REQUEST);



  1. By clicking on link spring boot will redirect to the angular's reset password page.

@RequestMapping(value = "/resetPassword", method = RequestMethod.GET)
public ModelAndView displayResetPasswordPage(@RequestParam("resetToken") String token) throws ParseException
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
Optional<User> user = userRepository.findUserByResetToken(token);
ModelAndView modelAndView = new ModelAndView();
if (user.isPresent()) // Token found in DB
if (simpleDateFormat.parse(user.get().getResetTokenExpiry()).after(new Date()))
modelAndView.addObject("resetToken", token);
modelAndView.setViewName("redirect:http://localhost:4200/reset-password");
else
modelAndView.addObject("errorMessage", "Oops! Your password reset link has expired.");
modelAndView.setViewName("redirect:http://localhost:4200/forgot-password");

else // Token not found in DB
modelAndView.addObject("errorMessage", "Oops! This is an invalid password reset link.");
modelAndView.setViewName("redirect:http://localhost:4200/forgot-password");

return modelAndView;



  1. By entering the new password on reset page, angular will pass the reset token and new password to spring boot and then spring boot should redirect to login page after successful change of password.

@RequestMapping(value = "/processResetPassword", method = RequestMethod.POST)
public ModelAndView setNewPassword(@RequestBody Map<String, String> requestParams, RedirectAttributes redir, HttpServletResponse response)
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
Optional<User> user = userRepository.findUserByResetToken(requestParams.get("resetToken"));
ModelAndView modelAndView = new ModelAndView();
if (user.isPresent())
User resetUser = user.get();
resetUser.setPassword(encoder.encode(requestParams.get("password")));
resetUser.setResetToken(null);
resetUser.setResetTokenExpiry(null);
resetUser.setModifiedBy(resetUser.getId());
resetUser.setModifiedDate(simpleDateFormat.format(new Date()));
userRepository.save(resetUser);
//redir.addFlashAttribute("successMessage", "You have successfully reset your password. You may now login.");
//modelAndView.addObject("successMessage", "You have successfully reset your password. You may now login.");
modelAndView.setViewName("redirect:http://localhost:4200");
return modelAndView;
else
modelAndView.addObject("errorMessage", "Oops! This is an invalid password reset link.");
modelAndView.setViewName("redirect:http://localhost:4200/forgot-password");

return modelAndView;



Now the problem is, in second point spring boot is able to redirect the reset password page perfectly but in third point while redirecting to login page it is giving CORS error. Why?



Here is the screenshot of error screenshot



Edit:
Here is cross origin annotation



@CrossOrigin(origins = "*", maxAge = 3600)
@RestController
@RequestMapping("/dis")
public class AuthRestAPIs ....


and here is the request header at network request header










share|improve this question
























  • I don't see an @CrossOrigin annotation anywhere, and you didn't show the HTTP headers from your network requests. As a note, passing HttpServletRequest is nearly always a sign that you are taking more trouble than is necessary. In this case, pass UriComponentsBuilder instead; you can use MvcUriComponentsBuilder.relativeTo to create the link you want in a much cleaner fashion.

    – chrylis
    Mar 23 at 6:58











  • @chrylis , Hey, I have update my question with @CrossOrigin and request header, please have a look and also, I am passing HttpServletRequest in forgotPassword method and that's working fine. Moreover, in setNewPassword method else part is working fine, it is perfectly redirect to forgot password page, so, i am confused that what's the problem with if part in the same, why it is providing null in request header origin

    – Divyani Garg
    Mar 23 at 7:26











  • Your CORS configuration needs to be updated so that the server sends back an Access-Control-Allow-Headers response header that includes 'Content-Type' in its value.

    – sideshowbarker
    Mar 23 at 23:34













1












1








1


1






I am developing an application with angular 6 as front end and spring boot as back end. Currently I am working with forgot password functionality :



  1. Taking email id from angular and sending an email to the id.

@RequestMapping(value = "/forgotPassword", method = RequestMethod.POST)
public ResponseEntity<?> forgotPassword(@RequestParam("email") String recepientemail, HttpServletRequest request)
Optional<User> userlist = userRepository.findByEmail(recepientemail);
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
if (userlist.isPresent())
User u = userlist.get();
u.setResetToken(UUID.randomUUID().toString());
u.setResetTokenExpiry(simpleDateFormat.format(DateUtils.addDays(new Date(), 1)));
u.setModifiedBy(u.getId());
u.setModifiedDate(simpleDateFormat.format(new Date()));
userRepository.save(u);
String appUrl = request.getScheme() + "://" + request.getServerName() + ":" + request.getLocalPort();

// Email message
email.sendSimpleEmail(u.getEmail(), "DIS Password Reset Request",
"To reset your password, click the link below:n" + appUrl + "/dis/resetPassword?resetToken="
+ u.getResetToken());
return new ResponseEntity<>(
new ResponseMessage("A password reset link has been sent to registered email address!"),
HttpStatus.OK);

return new ResponseEntity<>(new ResponseMessage("We didn't find an account for this e-mail address!"),
HttpStatus.BAD_REQUEST);



  1. By clicking on link spring boot will redirect to the angular's reset password page.

@RequestMapping(value = "/resetPassword", method = RequestMethod.GET)
public ModelAndView displayResetPasswordPage(@RequestParam("resetToken") String token) throws ParseException
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
Optional<User> user = userRepository.findUserByResetToken(token);
ModelAndView modelAndView = new ModelAndView();
if (user.isPresent()) // Token found in DB
if (simpleDateFormat.parse(user.get().getResetTokenExpiry()).after(new Date()))
modelAndView.addObject("resetToken", token);
modelAndView.setViewName("redirect:http://localhost:4200/reset-password");
else
modelAndView.addObject("errorMessage", "Oops! Your password reset link has expired.");
modelAndView.setViewName("redirect:http://localhost:4200/forgot-password");

else // Token not found in DB
modelAndView.addObject("errorMessage", "Oops! This is an invalid password reset link.");
modelAndView.setViewName("redirect:http://localhost:4200/forgot-password");

return modelAndView;



  1. By entering the new password on reset page, angular will pass the reset token and new password to spring boot and then spring boot should redirect to login page after successful change of password.

@RequestMapping(value = "/processResetPassword", method = RequestMethod.POST)
public ModelAndView setNewPassword(@RequestBody Map<String, String> requestParams, RedirectAttributes redir, HttpServletResponse response)
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
Optional<User> user = userRepository.findUserByResetToken(requestParams.get("resetToken"));
ModelAndView modelAndView = new ModelAndView();
if (user.isPresent())
User resetUser = user.get();
resetUser.setPassword(encoder.encode(requestParams.get("password")));
resetUser.setResetToken(null);
resetUser.setResetTokenExpiry(null);
resetUser.setModifiedBy(resetUser.getId());
resetUser.setModifiedDate(simpleDateFormat.format(new Date()));
userRepository.save(resetUser);
//redir.addFlashAttribute("successMessage", "You have successfully reset your password. You may now login.");
//modelAndView.addObject("successMessage", "You have successfully reset your password. You may now login.");
modelAndView.setViewName("redirect:http://localhost:4200");
return modelAndView;
else
modelAndView.addObject("errorMessage", "Oops! This is an invalid password reset link.");
modelAndView.setViewName("redirect:http://localhost:4200/forgot-password");

return modelAndView;



Now the problem is, in second point spring boot is able to redirect the reset password page perfectly but in third point while redirecting to login page it is giving CORS error. Why?



Here is the screenshot of error screenshot



Edit:
Here is cross origin annotation



@CrossOrigin(origins = "*", maxAge = 3600)
@RestController
@RequestMapping("/dis")
public class AuthRestAPIs ....


and here is the request header at network request header










share|improve this question
















I am developing an application with angular 6 as front end and spring boot as back end. Currently I am working with forgot password functionality :



  1. Taking email id from angular and sending an email to the id.

@RequestMapping(value = "/forgotPassword", method = RequestMethod.POST)
public ResponseEntity<?> forgotPassword(@RequestParam("email") String recepientemail, HttpServletRequest request)
Optional<User> userlist = userRepository.findByEmail(recepientemail);
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
if (userlist.isPresent())
User u = userlist.get();
u.setResetToken(UUID.randomUUID().toString());
u.setResetTokenExpiry(simpleDateFormat.format(DateUtils.addDays(new Date(), 1)));
u.setModifiedBy(u.getId());
u.setModifiedDate(simpleDateFormat.format(new Date()));
userRepository.save(u);
String appUrl = request.getScheme() + "://" + request.getServerName() + ":" + request.getLocalPort();

// Email message
email.sendSimpleEmail(u.getEmail(), "DIS Password Reset Request",
"To reset your password, click the link below:n" + appUrl + "/dis/resetPassword?resetToken="
+ u.getResetToken());
return new ResponseEntity<>(
new ResponseMessage("A password reset link has been sent to registered email address!"),
HttpStatus.OK);

return new ResponseEntity<>(new ResponseMessage("We didn't find an account for this e-mail address!"),
HttpStatus.BAD_REQUEST);



  1. By clicking on link spring boot will redirect to the angular's reset password page.

@RequestMapping(value = "/resetPassword", method = RequestMethod.GET)
public ModelAndView displayResetPasswordPage(@RequestParam("resetToken") String token) throws ParseException
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
Optional<User> user = userRepository.findUserByResetToken(token);
ModelAndView modelAndView = new ModelAndView();
if (user.isPresent()) // Token found in DB
if (simpleDateFormat.parse(user.get().getResetTokenExpiry()).after(new Date()))
modelAndView.addObject("resetToken", token);
modelAndView.setViewName("redirect:http://localhost:4200/reset-password");
else
modelAndView.addObject("errorMessage", "Oops! Your password reset link has expired.");
modelAndView.setViewName("redirect:http://localhost:4200/forgot-password");

else // Token not found in DB
modelAndView.addObject("errorMessage", "Oops! This is an invalid password reset link.");
modelAndView.setViewName("redirect:http://localhost:4200/forgot-password");

return modelAndView;



  1. By entering the new password on reset page, angular will pass the reset token and new password to spring boot and then spring boot should redirect to login page after successful change of password.

@RequestMapping(value = "/processResetPassword", method = RequestMethod.POST)
public ModelAndView setNewPassword(@RequestBody Map<String, String> requestParams, RedirectAttributes redir, HttpServletResponse response)
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
Optional<User> user = userRepository.findUserByResetToken(requestParams.get("resetToken"));
ModelAndView modelAndView = new ModelAndView();
if (user.isPresent())
User resetUser = user.get();
resetUser.setPassword(encoder.encode(requestParams.get("password")));
resetUser.setResetToken(null);
resetUser.setResetTokenExpiry(null);
resetUser.setModifiedBy(resetUser.getId());
resetUser.setModifiedDate(simpleDateFormat.format(new Date()));
userRepository.save(resetUser);
//redir.addFlashAttribute("successMessage", "You have successfully reset your password. You may now login.");
//modelAndView.addObject("successMessage", "You have successfully reset your password. You may now login.");
modelAndView.setViewName("redirect:http://localhost:4200");
return modelAndView;
else
modelAndView.addObject("errorMessage", "Oops! This is an invalid password reset link.");
modelAndView.setViewName("redirect:http://localhost:4200/forgot-password");

return modelAndView;



Now the problem is, in second point spring boot is able to redirect the reset password page perfectly but in third point while redirecting to login page it is giving CORS error. Why?



Here is the screenshot of error screenshot



Edit:
Here is cross origin annotation



@CrossOrigin(origins = "*", maxAge = 3600)
@RestController
@RequestMapping("/dis")
public class AuthRestAPIs ....


and here is the request header at network request header







java spring-boot cors preflight






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 23 at 23:33









sideshowbarker

34.7k1684100




34.7k1684100










asked Mar 23 at 6:15









Divyani GargDivyani Garg

438




438












  • I don't see an @CrossOrigin annotation anywhere, and you didn't show the HTTP headers from your network requests. As a note, passing HttpServletRequest is nearly always a sign that you are taking more trouble than is necessary. In this case, pass UriComponentsBuilder instead; you can use MvcUriComponentsBuilder.relativeTo to create the link you want in a much cleaner fashion.

    – chrylis
    Mar 23 at 6:58











  • @chrylis , Hey, I have update my question with @CrossOrigin and request header, please have a look and also, I am passing HttpServletRequest in forgotPassword method and that's working fine. Moreover, in setNewPassword method else part is working fine, it is perfectly redirect to forgot password page, so, i am confused that what's the problem with if part in the same, why it is providing null in request header origin

    – Divyani Garg
    Mar 23 at 7:26











  • Your CORS configuration needs to be updated so that the server sends back an Access-Control-Allow-Headers response header that includes 'Content-Type' in its value.

    – sideshowbarker
    Mar 23 at 23:34

















  • I don't see an @CrossOrigin annotation anywhere, and you didn't show the HTTP headers from your network requests. As a note, passing HttpServletRequest is nearly always a sign that you are taking more trouble than is necessary. In this case, pass UriComponentsBuilder instead; you can use MvcUriComponentsBuilder.relativeTo to create the link you want in a much cleaner fashion.

    – chrylis
    Mar 23 at 6:58











  • @chrylis , Hey, I have update my question with @CrossOrigin and request header, please have a look and also, I am passing HttpServletRequest in forgotPassword method and that's working fine. Moreover, in setNewPassword method else part is working fine, it is perfectly redirect to forgot password page, so, i am confused that what's the problem with if part in the same, why it is providing null in request header origin

    – Divyani Garg
    Mar 23 at 7:26











  • Your CORS configuration needs to be updated so that the server sends back an Access-Control-Allow-Headers response header that includes 'Content-Type' in its value.

    – sideshowbarker
    Mar 23 at 23:34
















I don't see an @CrossOrigin annotation anywhere, and you didn't show the HTTP headers from your network requests. As a note, passing HttpServletRequest is nearly always a sign that you are taking more trouble than is necessary. In this case, pass UriComponentsBuilder instead; you can use MvcUriComponentsBuilder.relativeTo to create the link you want in a much cleaner fashion.

– chrylis
Mar 23 at 6:58





I don't see an @CrossOrigin annotation anywhere, and you didn't show the HTTP headers from your network requests. As a note, passing HttpServletRequest is nearly always a sign that you are taking more trouble than is necessary. In this case, pass UriComponentsBuilder instead; you can use MvcUriComponentsBuilder.relativeTo to create the link you want in a much cleaner fashion.

– chrylis
Mar 23 at 6:58













@chrylis , Hey, I have update my question with @CrossOrigin and request header, please have a look and also, I am passing HttpServletRequest in forgotPassword method and that's working fine. Moreover, in setNewPassword method else part is working fine, it is perfectly redirect to forgot password page, so, i am confused that what's the problem with if part in the same, why it is providing null in request header origin

– Divyani Garg
Mar 23 at 7:26





@chrylis , Hey, I have update my question with @CrossOrigin and request header, please have a look and also, I am passing HttpServletRequest in forgotPassword method and that's working fine. Moreover, in setNewPassword method else part is working fine, it is perfectly redirect to forgot password page, so, i am confused that what's the problem with if part in the same, why it is providing null in request header origin

– Divyani Garg
Mar 23 at 7:26













Your CORS configuration needs to be updated so that the server sends back an Access-Control-Allow-Headers response header that includes 'Content-Type' in its value.

– sideshowbarker
Mar 23 at 23:34





Your CORS configuration needs to be updated so that the server sends back an Access-Control-Allow-Headers response header that includes 'Content-Type' in its value.

– sideshowbarker
Mar 23 at 23:34












0






active

oldest

votes












Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55311145%2fcors-error-while-redirecting-angular-page-from-spring-boot-header-field-content%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes















draft saved

draft discarded
















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55311145%2fcors-error-while-redirecting-angular-page-from-spring-boot-header-field-content%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

SQL error code 1064 with creating Laravel foreign keysForeign key constraints: When to use ON UPDATE and ON DELETEDropping column with foreign key Laravel error: General error: 1025 Error on renameLaravel SQL Can't create tableLaravel Migration foreign key errorLaravel php artisan migrate:refresh giving a syntax errorSQLSTATE[42S01]: Base table or view already exists or Base table or view already exists: 1050 Tableerror in migrating laravel file to xampp serverSyntax error or access violation: 1064:syntax to use near 'unsigned not null, modelName varchar(191) not null, title varchar(191) not nLaravel cannot create new table field in mysqlLaravel 5.7:Last migration creates table but is not registered in the migration table

은진 송씨 목차 역사 본관 분파 인물 조선 왕실과의 인척 관계 집성촌 항렬자 인구 같이 보기 각주 둘러보기 메뉴은진 송씨세종실록 149권, 지리지 충청도 공주목 은진현