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

restapi.php broken in 2.1.4 #74

Closed
bcleonard opened this issue Feb 25, 2024 · 8 comments
Closed

restapi.php broken in 2.1.4 #74

bcleonard opened this issue Feb 25, 2024 · 8 comments
Labels
installation About COPS installation

Comments

@bcleonard
Copy link

restapi.php is broken starting with release 2.1.4 (I suspect it was 2.1.3, but that was unreleased).

I noticed it when my homepage link using the api broke after the upgrade to 2.3.1.

When accessing /restapi.php, I get the following error: Fetch error Not Found /restapi.php/openapi

Please see the attached screenshots for a working/not-working.

cops_notworking
cops_working

I suspect that the openapi stuff has not been fully implemented. If that is the case, I recommend that you roll back the changes until its fully baked.

@mikespub
Copy link
Member

mikespub commented Feb 25, 2024

Hi @bcleonard thanks for the feedback. You may be the first besides myself to comment on this :-)

The REST API is something fairly new and it only works in dev mode since version 2.x, i.e. if you install COPS with all the required dev packages in composer.json

From my perspective the /restapi.php/openapi URL works fine, as you get a functional Swagger UI interface with all the APIs working properly when you try /restapi.php since version 2.1.4.

Of course, that's assuming you do have a working base URL for your installation. For example, in my Ubuntu wsl2 distribution I have a symlink from the COPS source repo to /var/www/html/cops with /var/www/html served with Apache, and I can access the REST API via http://localhost/cops/restapi.php for development, and similarly from my Synology NAS in production.

Does that help at all?

@mikespub
Copy link
Member

mikespub commented Feb 25, 2024

Hmm, actually never mind the dev mode - I moved nikic/fast-route to production around version 2.1.3 already.

The comment on the working base URL remains though, and yes, the functionality has changed a bit since the initial 1.3.6 release - sorry for the confusion.

The equivalent of the old restapi.php would now be restapi.php/index

Screenshot 2024-02-26 100532

@mikespub
Copy link
Member

mikespub commented Feb 26, 2024

Note: if you have a setup that requires the use of $config['cops_full_url'] this will now be used in restapi.php in release 2.4.1

/*
 * Full URL prefix (with trailing /)
 * useful especially for Opensearch where a full URL is often required
 * For example Mantano, Aldiko and Marvin require it.
 */
$config['cops_full_url'] = '';

@mikespub
Copy link
Member

mikespub commented Mar 4, 2024

Hi @bcleonard with the input above were you able to fix your homepage link?

@bcleonard
Copy link
Author

sorry, been way to busy the last week. I had a chance to test it this morning. I'm still not able to get the either the original api nor your new openapi url.

original_api_Screenshot 2024-03-04 112545

openapi_Screenshot 2024-03-04 112625

I pulled 2.4.1. I'm not using cops_full_url

@mikespub
Copy link
Member

mikespub commented Mar 4, 2024

With nginx in front of the COPS site, you probably need to double-check if it is configured to support PATH_INFO first - see https://www.nginx.com/resources/wiki/start/topics/examples/phpfcgi/

Then you may need to specify cops_full_url now in order to get the right absolute URLs instead of the relative URLs it used in older versions.

Once they're configured to reflect how you set up your environment, you should be good to go for all future versions :-)

@bcleonard
Copy link
Author

PATH_INFO was the issue. Once I enabled that, i can now get to the old restapi via /restapi.php/index.

BTW, I did not need to set cops_full_url

cops_working_restapi_openapi_Screenshot 2024-03-04 152535

cops_working_restapi_original_Screenshot 2024-03-04 152450

@mikespub
Copy link
Member

mikespub commented Mar 4, 2024

Glad it worked out :-)

BTW, if the PATH_INFO hadn't worked out, only a few /restapi.php/ paths are specific to the REST API itself.

For all standard COPS pages you could always fall back to using the old getJSON.php?page=... syntax too :-)

@mikespub mikespub closed this as completed Mar 4, 2024
@mikespub mikespub added installation About COPS installation labels May 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
installation About COPS installation
Projects
None yet
Development

No branches or pull requests

2 participants