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

SWA Local Testing #167

Closed
jpdom opened this issue Dec 11, 2023 · 4 comments
Closed

SWA Local Testing #167

jpdom opened this issue Dec 11, 2023 · 4 comments

Comments

@jpdom
Copy link

jpdom commented Dec 11, 2023

Hi!

I have been able to get authentication running locally by running SWA pointing to the local devserver:
swa start http://127.0.0.1:5173 --api-devserver-url http://127.0.0.1:5173

I am facing a problem related to the route /api/__render.
Here's what my svelte.config.js looks like:

import azure from 'svelte-adapter-azure-swa';
import { vitePreprocess } from '@sveltejs/kit/vite';
/** @type {import('@sveltejs/kit').Config} */
const config = {
	// Consult https://kit.svelte.dev/docs/integrations#preprocessors
	// for more information about preprocessors
	preprocess: [vitePreprocess({})],

	kit: {
		adapter: azure({
			customStaticWebAppConfig: {
				routes: [

					{
						route: '/workspace/',
						allowedRoles: ['authenticated']
					}
				],
				responseOverrides: {

					401: {
						redirect: "",
						statusCode: 302
					}
				},
				platform: {
					apiRuntime: 'node:18'
				}
			}
		})
	}
};

export default config;

And swa-cli-config.json:

{
  "configurations": {
    "app": {
      "outputLocation": "./build/static",
      "apiLocation": "./build/server",
      "host": "127.0.0.1"
    }
  }
}

The app runs and login/logout works but when I access the root url I get a not found error with these logs in the Vite terminal:

Error: Not found: /admin/functions
    at resolve (eval at instantiateModule (file:///C:/Users/joaop/OneDriveGW/OneDrive%20-%20WiseCompany/Documentos/Git/AI%20Suite/gw-ai-wkspc/node_modules/vite/dist/node/chunks/dep-68d1a114.js:56049:28), <anonymous>:491:13)   
    at resolve (eval at instantiateModule (file:///C:/Users/joaop/OneDriveGW/OneDrive%20-%20WiseCompany/Documentos/Git/AI%20Suite/gw-ai-wkspc/node_modules/vite/dist/node/chunks/dep-68d1a114.js:56049:28), <anonymous>:285:5)    
    at #options.hooks.handle (eval at instantiateModule (file:///C:/Users/joaop/OneDriveGW/OneDrive%20-%20WiseCompany/Documentos/Git/AI%20Suite/gw-ai-wkspc/node_modules/vite/dist/node/chunks/dep-68d1a114.js:56049:28), <anonymous>:56:56)
    at Module.respond (eval at instantiateModule (file:///C:/Users/joaop/OneDriveGW/OneDrive%20-%20WiseCompany/Documentos/Git/AI%20Suite/gw-ai-wkspc/node_modules/vite/dist/node/chunks/dep-68d1a114.js:56049:28), <anonymous>:282:40)
Error: Not found: /api/__render
    at resolve (eval at instantiateModule (file:///C:/Users/joaop/OneDriveGW/OneDrive%20-%20WiseCompany/Documentos/Git/AI%20Suite/gw-ai-wkspc/node_modules/vite/dist/node/chunks/dep-68d1a114.js:56049:28), <anonymous>:491:13)   
    at resolve (eval at instantiateModule (file:///C:/Users/joaop/OneDriveGW/OneDrive%20-%20WiseCompany/Documentos/Git/AI%20Suite/gw-ai-wkspc/node_modules/vite/dist/node/chunks/dep-68d1a114.js:56049:28), <anonymous>:285:5)    
    at #options.hooks.handle (eval at instantiateModule (file:///C:/Users/joaop/OneDriveGW/OneDrive%20-%20WiseCompany/Documentos/Git/AI%20Suite/gw-ai-wkspc/node_modules/vite/dist/node/chunks/dep-68d1a114.js:56049:28), <anonymous>:56:56)
    at Module.respond (eval at instantiateModule (file:///C:/Users/joaop/OneDriveGW/OneDrive%20-%20WiseCompany/Documentos/Git/AI%20Suite/gw-ai-wkspc/node_modules/vite/dist/node/chunks/dep-68d1a114.js:56049:28), <anonymous>:282:40)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)

And these on the SWA terminal:

[swa] ✖  ↳ GET http://127.0.0.1:5173/api/__render - 502 (Bad Gateway)
[swa] GET http://127.0.0.1:5173/api/__render (proxy)
[swa] ✖  ↳ GET http://127.0.0.1:5173/api/__render - 502 (Bad Gateway)

Any clues on what might be going on ?

@jpdom
Copy link
Author

jpdom commented Dec 11, 2023

Just tested by deleting the build folder, the SWA CLI isn't able to find a config file and everything works fine it kind of works, I get ECONNREFUSED errors on ::1 (ipv6??) That cause communication problems between the frontend and the backend.

@geoffrich
Copy link
Owner

Are you able to provide a sample repo that repros the issue?

Local dev with the SWA CLI is something I want to get back to. There's some discussion in #96 if you haven't already seen it.

@jpdom
Copy link
Author

jpdom commented Jan 27, 2024

Hi @geoffrich !
Not really I don't have a sample repo.. We ended up actually moving to Firebase because of the constant troubles we were having with Azure SWA.
This should be pretty easy to reproduce though, just following the SWA Adapter docs and trying to run the app locally won't work smoothly for anyone.

@geoffrich
Copy link
Owner

I'll close this in favor of #96.

@geoffrich geoffrich closed this as not planned Won't fix, can't repro, duplicate, stale Jan 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants