mirror of
				https://github.com/Unleash/unleash.git
				synced 2025-10-27 11:02:16 +01:00 
			
		
		
		
	fix: use the frontend dir from the backend
This commit is contained in:
		
							parent
							
								
									5c129cf1fa
								
							
						
					
					
						commit
						a4b3f9e70c
					
				| @ -125,7 +125,6 @@ | ||||
|     "ts-toolbelt": "^9.6.0", | ||||
|     "type-is": "^1.6.18", | ||||
|     "unleash-client": "3.15.0", | ||||
|     "unleash-frontend": "4.15.0-beta.1", | ||||
|     "uuid": "^8.3.2" | ||||
|   }, | ||||
|   "devDependencies": { | ||||
|  | ||||
| @ -1,4 +1,3 @@ | ||||
| import { publicFolder } from 'unleash-frontend'; | ||||
| import express, { Application, RequestHandler } from 'express'; | ||||
| import compression from 'compression'; | ||||
| import favicon from 'serve-favicon'; | ||||
| @ -22,6 +21,7 @@ import noAuthentication from './middleware/no-authentication'; | ||||
| import secureHeaders from './middleware/secure-headers'; | ||||
| 
 | ||||
| import { loadIndexHTML } from './util/load-index-html'; | ||||
| import { findPublicFolder } from './util/findPublicFolder'; | ||||
| 
 | ||||
| export default async function getApp( | ||||
|     config: IUnleashConfig, | ||||
| @ -32,7 +32,7 @@ export default async function getApp( | ||||
|     const app = express(); | ||||
| 
 | ||||
|     const baseUriPath = config.server.baseUriPath || ''; | ||||
| 
 | ||||
|     const publicFolder = findPublicFolder(); | ||||
|     let indexHTML = await loadIndexHTML(config, publicFolder); | ||||
| 
 | ||||
|     app.set('trust proxy', true); | ||||
|  | ||||
							
								
								
									
										5
									
								
								src/lib/util/findPublicFolder.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										5
									
								
								src/lib/util/findPublicFolder.ts
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,5 @@ | ||||
| import path from 'path'; | ||||
| 
 | ||||
| export const findPublicFolder = (): string => { | ||||
|     return path.join(__dirname, '..', '..', '..', 'frontend', 'build'); | ||||
| }; | ||||
| @ -1,9 +1,11 @@ | ||||
| import fs from 'fs'; | ||||
| import path from 'path'; | ||||
| import { rewriteHTML } from './rewriteHTML'; | ||||
| import { publicFolder } from 'unleash-frontend'; | ||||
| import { findPublicFolder } from './findPublicFolder'; | ||||
| 
 | ||||
| const input = fs.readFileSync(path.join(publicFolder, 'index.html')).toString(); | ||||
| const input = fs | ||||
|     .readFileSync(path.join(findPublicFolder(), 'index.html')) | ||||
|     .toString(); | ||||
| 
 | ||||
| test('rewriteHTML substitutes meta tag with existing rewrite value', () => { | ||||
|     const result = rewriteHTML(input, '/hosted'); | ||||
|  | ||||
| @ -77,6 +77,7 @@ | ||||
|     "snapshots", | ||||
|     "coverage", | ||||
|     "website", | ||||
|     "scripts" | ||||
|     "scripts", | ||||
|     "frontend" | ||||
|   ] | ||||
| } | ||||
|  | ||||
| @ -7243,11 +7243,6 @@ unleash-client@3.15.0: | ||||
|     murmurhash3js "^3.0.1" | ||||
|     semver "^7.3.5" | ||||
| 
 | ||||
| unleash-frontend@4.15.0-beta.1: | ||||
|   version "4.15.0-beta.1" | ||||
|   resolved "https://registry.yarnpkg.com/unleash-frontend/-/unleash-frontend-4.15.0-beta.1.tgz#c98255af5408c7cce3aa5f3a38fe2c634813a93b" | ||||
|   integrity sha512-6kHYetlytLVibTfi+QAweve7YWFmXdWzl6aDcYg2XMYj2Ago0gMHwTqtkG7JfZonG1vU5dkfk/KwBKTFKLJn/g== | ||||
| 
 | ||||
| unpipe@1.0.0, unpipe@~1.0.0: | ||||
|   version "1.0.0" | ||||
|   resolved "https://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz" | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user