Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

404 when using fullPath in Aliases and CORS #269

Closed
pibi opened this issue Aug 30, 2021 · 4 comments
Closed

404 when using fullPath in Aliases and CORS #269

pibi opened this issue Aug 30, 2021 · 4 comments
Assignees
Labels

Comments

@pibi
Copy link

pibi commented Aug 30, 2021

We are using moleculer-web 0.9.1 for an API service. We use a lot of custom APIs with fullPath and autoalias. We have noticed that the API-GW cors code doesn't match the route when the path doesn't start with the routes path. In this case the cors preflight doesn't work, it returns a 404.

To show you the issue, we have managed to reproduce it in the API-GW by using the aliases:

		routes: [
			{
				path: "/api",
				
				aliases: {
					"welcome": {
						method: "POST",
						fullPath: "/welcome",
						action: "greeters.welcome"
					}
				},
			}
		],				
				
[2021-08-30T16:57:58.361Z] INFO  spectrex360-34464/API: Register route to '/api'
[2021-08-30T16:57:58.362Z] INFO  spectrex360-34464/API:     POST /welcome => greeters.welcome
[2021-08-30T16:58:12.621Z] DEBUG spectrex360-34464/API: undefined
[2021-08-30T16:58:12.622Z] INFO  spectrex360-34464/API: <= 404 OPTIONS /welcome [+1.032 ms]

if the fullPath starts with the route path, the cors is correctly set:

				aliases: {
					"welcome": {
						method: "POST",
						fullPath: "/api/welcome",
						action: "greeters.welcome"
					}
				},
[2021-08-30T16:56:46.501Z] INFO  spectrex360-34464/API: Register route to '/api'
[2021-08-30T16:56:46.505Z] INFO  spectrex360-34464/API:     POST /api/welcome => greeters.welcome
[2021-08-30T16:57:21.114Z] INFO  spectrex360-34464/API: => OPTIONS /welcome
[2021-08-30T16:57:21.115Z] INFO  spectrex360-34464/API: <= 204 OPTIONS /api/welcome [+1.492 ms]
@intech intech added the bug label Aug 30, 2021
@intech
Copy link
Member

intech commented Aug 30, 2021

Confirmed on version 0.10.0

@intech intech self-assigned this Aug 31, 2021
@icebob
Copy link
Member

icebob commented Sep 1, 2021

The problem is that, there is no registered handler for the path with OPTIONS method.
Here is a workaround:
image

@icebob
Copy link
Member

icebob commented Sep 1, 2021

It can solve it, but I don't know it doesn't cause other issues...e.g It can find a GET alias and not the POST
image

@icebob icebob closed this as completed in 4722f78 Sep 1, 2021
@icebob
Copy link
Member

icebob commented Sep 1, 2021

Fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants