apioo / fusio

Open source API management platform

Home Page:https://www.fusio-project.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Refresh developer page cause internal server error

cococonuts opened this issue · comments

I use nginx. Do you know how to solve the issue? Is it related to Nginx? configuration? or router

Description:
I can navigate to Authorization page by clicking "Authorization" on the nav bar
1

However, when I am on Authorization page then refresh Authorization page, it raise "internal server error"
2

Is it related to rewrite config in nginx or
// To enable clean urls you need to set this to '' this works only in case mod rewrite is activated
'psx_dispatch' => 'index.php/',

More information about this issue. Does anybody knows how to fix it?

When I click "Get started" on navigation bar , in debug console, it shows
GET https://myhost.com/index.php/consumer/page/~getting-started
It works.

when I click "Get started" on the page, in debug console, it shows
scheme | https
host | myhost.com
filename | /apps/developer/bootstrap
response: "internal server error"

screenshot

Is it an issue of Angular router?

Hi @cococonuts, so if you click on the link it will request the content of the page through an AJAX call to the /consumer/page/~getting-started endpoint but this should happen only at the background. It looks like your web server does not redirect the request to the index.html of the angular developer app but instead it redirects the request to Fusio which does not know such a route.

At Fusio for Apache we have a special rewrite rule s.
https://github.com/apioo/fusio/blob/master/public/.htaccess#L2
which excludes everything under /apps your would need to find a similar logic also for nginx. So all urls except for /apps are redirected to the index.php as alternative you could also host all apps on a separated sub-domain i.e. apps.myapi.com in this case it would be much simple since you would have two domains.

@chriskapp Thank you for response.

I added a rule in nginx which may be equivalent with RewriteCond %{REQUEST_URI} !^/apps/ in apache.
if ($uri !~ ^/apps/) {
rewrite ^(.*)$ /index.php?$1 last;
}
But it doesn't work.
`server {
root /var/www/fusio/html/public;
index index.html index.htm index.nginx-debian.html index.php;
server_name antaresapi.com;

location / {
if ($uri !~ ^/apps/) {
rewrite ^(.*)$ /index.php?$1 last;
}
try_files $uri $uri/ /index.php$is_args$args;
}

My nginx config
`server {
root /var/www/fusio/html/public;
index index.html index.htm index.nginx-debian.html index.php;
server_name myhost.com;

location / {
if ($uri !~ ^/apps/) {
rewrite ^(.*)$ /index.php?$1 last;
}
try_files $uri $uri/ /index.php$is_args$args;
}

location ~ .php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/var/run/php/php8.2-fpm.sock;

fastcgi_split_path_info ^(.+.php)(/.*)$;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
fastcgi_param DOCUMENT_ROOT $realpath_root;
}
}`

Could you share some documents about how to host apps in a sub-domain?

I took a look at the the rewrite rule log of nginx:
Using navigation bar(works correctly):
http upstream request: "/index.php?/index.php/consumer/page/~getting-started"

Click "Get started" in page or refresh page(works incorrectly):
http upstream request: "/apps/developer/bootstrap"
with rewrite rule:
it will be "/index.php/apps/developer/bootstrap" but with this url, it still can't go to the right place.

I just guess, it might be a issue in Angular App.
I have not dig fusio deep. I might be wrong.

Do you have any thoughts?

I took a look at the the rewrite rule log of nginx:
Using navigation bar(works correctly):
http upstream request: "/index.php?/index.php/consumer/page/~getting-started"

Click "Get started" in page or refresh page(works incorrectly):
http upstream request: "/apps/developer/bootstrap"
with rewrite rule:
it will be "/index.php?/index.php/apps/developer/bootstrap" but with this url, it still can't go to the right place.

Which rule / router can make /apps/developer/bootstrap rewritten to "/index.php?/index.php/consumer/page/~getting-started"

I just guess, it might be a issue in Angular App.
I have not dig fusio deep. I might be wrong.

Do you have any thoughts?

@chriskapp
I found your demo site also use nginx. Would you mind sharing your nginx config?
image

@chriskapp Thank you very much!
I host developer app on a separated sub-domain as you said. It works for me now.

@cococonuts great that this works, in general regarding the demo, we also only use nginx as reverse proxy to our docker image so the complete rewrite config is still using apache and mod rewrite which is configured at our docker image.

@cococonuts can you share an example of your nginx config for the subdomain you configured?