title: Laravel api put-request: why does it work locally, and not on the server?
body: <p>My app runs fine locally.
  I can create and add cards with pictures.</p>
  <p>Now I try to deploy the app ( first time I deploy a complete self made application...).
  Probably I made a basic mistake. Just cannot figure out what it is...</p>
  <p>On the get a 405 error message : The server returned a &quot;405 Method Not Allowed&quot;.</p>
  <p>The laravel/storage/logs/laravel.log show no errors.</p>
  <pre><code>     public function store(Request $request)
      {
  
          //logger($request-&gt;all());
          //validate data first
          $request-&gt;validate([
              'description'=&gt; 'required'
          ]);
  
          
          $card = $request-&gt;all();
         
          if ($request-&gt;hasFile('imagefile')){
          
              $this-&gt;validate($request, ['picture' =&gt; 'max:2000'], ['Maximum file size of 2MB allowed']);
  
              $image = $request-&gt;file('imagefile'); //file_picture_input  is naam van file inputveld in het formulier, de naam die de request aan de file geeft
             
                  $image_name = strval(time().Str::random(5)).$image-&gt;getClientOriginalName();
                  
              $img = Image::make($image);
              $img-&gt;resize(300, 300, function ($constraint) {
                      $constraint-&gt;aspectRatio();
                  });
                  $image-&gt;storeAs('images',$image_name,'public');  // store in subdir 'ímages, in disk: 'public' dus storage/app/public/images
  
                  $path = asset('storage/images/'.$image_name);  // omdat storage:link is gedaan, is storage == storage/app/public/
              
                  $card['picture'] = $path;
          }
          else {
              $card['picture'] = 'img/profile/default_avatar.png';
          }
      
          //create a post
          return response(Card::create($card),201);
      }
  </code></pre>
  <p>This is the vue component method calling the api:</p>
  <pre><code>        addCard(){
              // de informatie voor de card staat inthis.$card, nu omzetten naar FormData om file toe te voegen aan de request zodat api die kan opslaan, api gaat ook naam bedenken voor de card.
              //  via fetchCards() komt die naam dadelijk terug in card.picture
              const formData = new FormData();
              formData.append('title',this.card.title);
              formData.append('description',this.card.description);
              formData.append('imagefile',this.selectedFile);
              formData.append('speler_id', this.currentSpeler.speler.id);
              formData.append('game_id', this.currentGame.id);
             
             
  
              if(this.edit === false){  // eerste keer dat kaart wordt getoond is edit ===false, als er dan geen kaart is, wordt er een toegevoegd
                  //add
                  fetch(`api/cards`, {
                      method: 'post',
                      body:formData,
                      headers:{
                          //'content-type': 'multipart/form-data',
                         // 'accept':'application/json'
                      }
                  })
                  .then(res =&gt; console.log(res))
              
                  .then(data =&gt; {
                      this.card.title='';
                      this.card.description='';
                      this.card.picture='';
                      this.$refs.fileUpload.value=null;
                      this.url='';
                      this.showSpelerCards();
                  })
                  .catch(err =&gt; console.log(err));
              } else{   // als je hier belandt via editCard functie, dan is de editCard ===true, en kom je hier terecht
                  //update
                  fetch(`api/cards/${this.card.id}?_method=PUT`, {
                      method: 'post',
                      body:formData,
                      headers:{
                         // 'content-type': 'multipart/form-data',
                          //'accept':'application/json'
                      }
                  })
                  //.then(res =&gt; res.formData())
                  .then(res =&gt; console.log(res))
                  .then(data =&gt; {
                      this.card.title='';
                      this.card.description='';
                     // alert('Card updated');
                     this.url='';
                      this.$refs.fileUpload.value=null;
                      this.showSpelerCards();
                  })
                  .catch(err =&gt; console.log(err));
              }
          },
  </code></pre>
  <p>The route is:</p>
  <pre><code> Route::apiResource('/cards', 'App\Http\Controllers\CardController');
  </code></pre>
  <p>Locally everything works fine, on the VPS it fails. So I do not make a fundamental error...</p>
  <p>Can any one see what might be the problem?</p>