Azure Static Web Apps. For bugs and feature requests, please create an issue in this repo. For community discussions, latest updates, kindly refer to the Discussions Tab. To know what's new in Static Web Apps, visit https://aka.ms/swa/ThisMonth
I am deploying a nextjs app on Azure Static Web Apps and there is an issue loading the root url path, the index.html file is only loaded without triggering nextjs. However when loading a subpath (e.g. root.com/mypath/ ) the app loads successfully. Both root path and subpaths work fine on localhost.
The app is configured using the catch-all route [...params].tsx along with the Index.tsx file located under the pages folder. Also using SSR. I don't have any staticwebapp.config.json file configured.
Any idea why loading the app on the root path is not working when it works for subpaths?
To Reproduce
Steps to reproduce the behavior:
This works fine on localhost but not on deployed url.
name: Azure Static Web Apps CI/CD
on:
push:
branches:
- main
- staging
pull_request:
types: [opened, synchronize, reopened, closed]
branches:
- main
jobs:
build_and_deploy_job:
if: github.event_name == 'push' || (github.event_name == 'pull_request' && github.event.action != 'closed')
runs-on: ubuntu-latest
name: Build and Deploy Job
steps:
- uses: actions/checkout@v3
with:
submodules: true
- name: Build And Deploy
id: builddeploy
uses: Azure/static-web-apps-deploy@v1
with:
azure_static_web_apps_api_token: ${{ secrets.token }}
repo_token: ${{ secrets.token }} # Used for Github integrations (i.e. PR comments)
action: "upload"
###### Repository/Build Configurations - These values can be configured to match your app requirements. ######
# For more information regarding Static Web App workflow configurations, please visit: https://aka.ms/swaworkflowconfig
app_location: "/" # App source code path
api_location: "" # Api source code path - optional
output_location: "" # Built app content directory - optional
###### End of Repository/Build Configurations ######
production_branch: "main"
env:
close_pull_request_job:
if: github.event_name == 'pull_request' && github.event.action == 'closed'
runs-on: ubuntu-latest
name: Close Pull Request Job
steps:
- name: Close Pull Request
id: closepullrequest
uses: Azure/static-web-apps-deploy@v1
with:
azure_static_web_apps_api_token: ${{ secrets.token }}
action: "close"
Expected behavior
The deployed root url should render the nextjs app
Describe the bug
I am deploying a nextjs app on Azure Static Web Apps and there is an issue loading the root url path, the index.html file is only loaded without triggering nextjs. However when loading a subpath (e.g. root.com/mypath/ ) the app loads successfully. Both root path and subpaths work fine on localhost.
The app is configured using the catch-all route [...params].tsx along with the Index.tsx file located under the pages folder. Also using SSR. I don't have any staticwebapp.config.json file configured.
Any idea why loading the app on the root path is not working when it works for subpaths?
To Reproduce Steps to reproduce the behavior: This works fine on localhost but not on deployed url.
Expected behavior The deployed root url should render the nextjs app
Screenshots
Device info (if applicable):