SHARE
TWEET

Untitled

a guest Oct 3rd, 2017 91 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. @Bean
  2. public FilterRegistrationBean corsFilter() {
  3.     CorsConfiguration config = new CorsConfiguration();
  4.     config.addAllowedOrigin("https://example.com");
  5.     config.addAllowedHeader("*");
  6.     config.addAllowedMethod("GET");
  7.     config.addAllowedMethod("PUT");
  8.     config.addAllowedMethod("POST");
  9.     config.addAllowedMethod("DELETE");
  10.     config.addAllowedMethod("PATCH");
  11.  
  12.     UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();
  13.     source.registerCorsConfiguration("/**", config);
  14.  
  15.     FilterRegistrationBean bean = new FilterRegistrationBean(new CorsFilter(source));
  16.     bean.setOrder(Ordered.HIGHEST_PRECEDENCE);
  17.     return bean;
  18. }
  19.    
  20. server {
  21.     ...
  22.  
  23.     location / {
  24.         proxy_pass http://localhost:3000;
  25.         proxy_http_version 1.1;
  26.         proxy_set_header Upgrade $http_upgrade;
  27.         proxy_set_header Connection 'upgrade';
  28.         proxy_set_header Host $host;
  29.         proxy_cache_bypass $http_upgrade;
  30.     }
  31.  
  32.     location /api/v1/ {
  33.         proxy_pass http://localhost:3001;
  34.         proxy_http_version 1.1;
  35.         proxy_set_header Upgrade $http_upgrade;
  36.         proxy_set_header Connection 'upgrade';
  37.         proxy_set_header Host $host;
  38.         proxy_cache_bypass $http_upgrade;
  39.     }
  40.  
  41.     ...
  42. }
  43.    
  44. "$request" $status "$http_referer" "$http_user_agent"
  45.    
  46. "OPTIONS /api/v1/oauth/token?grant_type=password&username=user%40example.com&password=****" 403 "https://www.example.com/login" "Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3163.100 Safari/537.36"
  47.    
  48. "OPTIONS /api/v1/oauth/token?grant_type=password&username=user%40example.com&password=****" 403 "-" "Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; rv:11.0) like Gecko"
  49.    
  50. URL: https://example.com:3001/api/v1/oauth/token?grant_type=password&username=user%40example.com&password=****
  51. Method: POST
  52. Headers:
  53.     Authorization: Basic XXXXXXXXXXX=
  54.     Content-Type: application/x-www-form-urlencoded
  55. Body: undefined
  56.    
  57. OPTIONS /api/v1/oauth/token?grant_type=password&username=user%40example.com&password=**** HTTP/1.1
  58. Host: https://example.com:3001
  59. Connection: keep-alive
  60. Access-Control-Request-Method: POST
  61. Origin: https://example.com:3000
  62. User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3163.79 Safari/537.36
  63. Access-Control-Request-Headers: authorization
  64. Accept: */*
  65. Referer: https://example.com:3000/login
  66. Accept-Encoding: gzip, deflate
  67. Accept-Language: en-US,en;q=0.8,sv;q=0.6
  68.    
  69. HTTP/1.1 200
  70. Access-Control-Allow-Origin: https://example.com:3000
  71. Vary: Origin
  72. Access-Control-Allow-Methods: GET,PUT,POST,DELETE,PATCH
  73. Access-Control-Allow-Headers: authorization
  74. Content-Length: 0
  75. Date: Tue, 03 Oct 2017 16:01:37 GMT
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top