404 Error on API requests

I was experimenting with API endpoints construction, by using the suggested October CMS 3 method.
Everything was working fine, but all of a sudden I get 404 errors, when making the requests. I found that the requests only work from the browser if I’m logged in to the October CMS backend.
Previously, the requests worked without being authenticated and also from Postman or the Thunder Client in Visual Studio Code.
The only change I’m aware of is the installation of two extensions for VSC: “October Twig” and “October Tools”.

This is an example of my setup:

I have a page in the active template: “apiv1_blogposts.htm”

This is the code:

title = "Blog Posts"
layout = "default"
url = "/api-v1/blogposts/:status?published/:language?en"

[collection blogposts]
handle = "Content\BlogPost"
==

{% set result = collect() %}

{% set selectedPosts = blogposts.where('status', this.param.status).get() %}

{% for post in selectedPosts %}
    {% do result.push({
            id: post.id,
            title: post.title,
            lang: post.language,
            status: post.status,
            created_at: post.created_at,
            updated_at: post.updated_at,
            content: post.content,
            param: this.param.status
    }) %}
{% endfor %}

So, If I test this URL:

http://localhost:8082/api-v1/blogposts

I get a 404 error page, except if the backend user session is initiated.

What I am missing?

Thanks in advance.

It sounds like the theme might change when you are logged in to the backend vs not logged in. Can you confirm that the same theme is displayed in both cases?

Hello.

I’m seeing different 404 error pages in the browser, depending on the logged in status.

I’m confused about this.

I installed the Vanilla theme during my early tests and currently using a child theme based on Vanilla.

Any suggestions?

It seems that I had a mess with the templates. I deleted all of them except Demo and then reinstalled Vanilla. Restored the backup of the API pages I previously had, and now it works without issues.

Thanks for the support.