diff --git a/conf/nginx.conf b/conf/nginx.conf index 20a917d..3df721e 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -1,4 +1,4 @@ -location / { +location __PATH__/ { # Standard nginx configuration proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; @@ -6,7 +6,7 @@ location / { proxy_set_header Host $http_host; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; - proxy_pass http://localhost:__PORT__; + proxy_pass http://localhost:__PORT__/__PATH__; # Include SSOWAT user panel. include conf.d/yunohost_panel.conf.inc; diff --git a/manifest.toml b/manifest.toml index fd66344..a3e1961 100644 --- a/manifest.toml +++ b/manifest.toml @@ -27,6 +27,10 @@ ram.runtime = "50M" [install.domain] type = "domain" + [install.path] + type = "path" + default = "/" + [install.init_main_permission] type = "group" default = "visitors" diff --git a/scripts/change_url b/scripts/change_url index f36786b..d49c586 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -36,13 +36,29 @@ then ynh_replace_string --match_string="NEXT_PUBLIC_SITE_DOMAIN=$old_domain" --replace_string="NEXT_PUBLIC_SITE_DOMAIN=$new_domain" --target_file="$install_dir/.env.local" fi +if [ $change_path -eq 1 ] +then + if [ "$old_path" = "/" ]; then + old_next_path="" + else + old_next_path=$old_path + fi + + if [ "$new_path" = "/" ]; then + new_next_path="" + else + new_next_path=$new_path + fi + + ynh_replace_string --match_string="module.exports = { basePath: '$old_path', };" --replace_string="module.exports = { basePath: '$new_path', };" +fi + #================================================= # REBUILDING AND INSTALL THE APP #================================================= ynh_script_progression --message="Rebuilding the app..." --weight=1 ynh_use_nodejs -ynh_exec_warn_less ynh_exec_as $app $ynh_node_load_PATH $ynh_npm install --prefix="$install_dir" npx next telemetry disable ynh_exec_warn_less ynh_exec_as $app $ynh_node_load_PATH $ynh_npm run build --prefix="$install_dir" diff --git a/scripts/install b/scripts/install index b29b4c6..7921233 100755 --- a/scripts/install +++ b/scripts/install @@ -50,6 +50,18 @@ ynh_add_config --template=".env.local" --destination="$install_dir/.env.local" chmod 400 "$install_dir/.env.local" chown $app:$app "$install_dir/.env.local" +#================================================= +# CONFIGURATION FOR SUBPATH +#================================================= + +if [ "$path" = "/" ]; then + next_path="" +else + next_path=$path +fi + +echo "module.exports = { basePath: '$next_path', };" >> "$install_dir/next.config.js" + #================================================= # BUILD AND INSTALL THE APP #================================================= diff --git a/scripts/remove b/scripts/remove index 5f184b4..0d88fec 100755 --- a/scripts/remove +++ b/scripts/remove @@ -42,10 +42,6 @@ ynh_remove_systemd_config ynh_remove_nginx_config -# Remove other various files specific to the app... such as : - -ynh_secure_remove --file="/var/log/$app" - #================================================= # END OF SCRIPT #=================================================