feathersjs / feathers

The API and real-time application framework
https://feathersjs.com
MIT License
14.97k stars 742 forks source link

Calls to feathers services with HEAD method are throwing an error since v5.x. #3464

Open agodefroyLeni opened 2 months ago

agodefroyLeni commented 2 months ago

Hello,

Steps to reproduce

Create a simple service :

info.service.js

import Info from './info.class';
import hooks from './info.hooks';

export default function (app) {

  app.use(
    '/v1/info',
    new Info({}, app)
  );

  const service = app.service('/v1/info');
  service.hooks(hooks);
}

info.class.js :

import { MethodNotAllowed } from '@feathersjs/errors';
import fse from 'fs-extra';

class Info {
  async setup(app) {
    this.app = app;
  }

  async find() {
    const { version } = await fse.readJson('./package-lock.json');
    return { version };
  }

  async get()
  {
    throw new MethodNotAllowed();
  }
}

export default Info;

Expected behavior

To return a 200 code.

Actual behavior

Throwing a 500 error.

System configuration

Tell us about the applicable parts of your setup.

Module versions (especially the part that's not working): 5.0.21

NodeJS version: 20.11.1

Operating System: Ubuntu 22.04.3

Module Loader: commonJs

daffl commented 2 months ago

Are you using Express or Koa? What did it return before?

agodefroyLeni commented 2 months ago

Are you using Express or Koa? What did it return before?

I'm using express. It used tu return a 200 code.