2014-02-24 55 views
0

我目前正在嘗試發佈到我的heroku服務器。 本地一切工作正常,但如果我更改我的網址爲AFHttpSessionmanager到heroku應用程序,我的應用程序將不再工作,導致發佈請求被解釋爲GET請求在Heroku端..AFNetworkings的POST請求AFHTTPSessionManager在Heroku上被解釋爲GET

這就是我後請求:

NSString * postPath = [NSString stringWithFormat:@"/freetextquestions/%ld/freetextanswers.json",(long)identifier]; 
     [[AskMeClient sharedClient] POST:postPath parameters: [NSDictionary dictionaryWithObject:self.answerTextField.text forKey:@"text"] 
             success:^(NSURLSessionDataTask *task, id responseObject) { 
              NSLog(@"%@", responseObject); 
              [self dismissViewControllerAnimated:YES completion:nil]; 
             } failure:^(NSURLSessionDataTask *task, NSError *error) { 
              NSLog(@"%@", error); 
              UIAlertView * alert = [[UIAlertView alloc]initWithTitle:@"Ooops ..." message:error.localizedDescription delegate:nil cancelButtonTitle:@"dismiss" otherButtonTitles: nil]; 
              [alert show]; 

             }]; 

這是我的客戶:

@implementation AskMeClient 

+(instancetype)sharedClient { 
    static AskMeClient *_sharedClient = nil; 
    static dispatch_once_t onceToken; 
    dispatch_once(&onceToken, ^{ 
     _sharedClient = [[AskMeClient alloc] initWithBaseURL:[NSURL URLWithString:AskMeAPIBaseURLString]]; 
     _sharedClient.securityPolicy = [AFSecurityPolicy defaultPolicy]; 
     _sharedClient.responseSerializer = [AFJSONResponseSerializer serializer]; 
     _sharedClient.requestSerializer = [AFJSONRequestSerializer serializer]; 
     [_sharedClient.requestSerializer setValue:@"application/json" forHTTPHeaderField:@"Accept"]; 
    }); 

    return _sharedClient; 
} 
@end 

,這是什麼Heroku的說:

2014-02-24T00:32:35.246169+00:00 heroku[router]: at=info method=GET path=/freetextquestions/3/freetextanswers host=topsecretapp.herokuapp.com request_id=b2876fdb-d4bf-403a-a05a-4539830f9f0e fwd="193.175.119.11" dyno=web.1 connect=9ms service=44ms status=404 bytes=351 

我試過一切消除這個錯誤,但我不能讓它工作.. 有沒有人有一個想法我做錯了什麼?或者這是Heroku-Error?

回答

0

我找到了解決方案。 如果我使用由heroku提供的子域,似乎HTTP方法會以某種方式丟失,可能是由某些轉發或重定向造成的。 現在我正在使用其他域引用我的heroku-App,一切正常。